How to use setup_bridge method in lisa

Best Python code snippet using lisa_python

test_deconz.py

Source:test_deconz.py Github

copy

Full Screen

...38 "type": "On/Off plug-in unit",39 "state": {}40 }41}42async def setup_bridge(hass, data, allow_deconz_groups=True):43 """Load the deCONZ light platform."""44 from pydeconz import DeconzSession45 loop = Mock()46 session = Mock()47 entry = Mock()48 entry.data = {'host': '1.2.3.4', 'port': 80, 'api_key': '1234567890ABCDEF'}49 bridge = DeconzSession(loop, session, **entry.data)50 with patch('pydeconz.DeconzSession.async_get_state',51 return_value=mock_coro(data)):52 await bridge.async_load_parameters()53 hass.data[deconz.DOMAIN] = bridge54 hass.data[deconz.DATA_DECONZ_UNSUB] = []55 hass.data[deconz.DATA_DECONZ_ID] = {}56 config_entry = config_entries.ConfigEntry(57 1, deconz.DOMAIN, 'Mock Title',58 {'host': 'mock-host', 'allow_deconz_groups': allow_deconz_groups},59 'test')60 await hass.config_entries.async_forward_entry_setup(config_entry, 'light')61 # To flush out the service call to update the group62 await hass.async_block_till_done()63async def test_no_lights_or_groups(hass):64 """Test that no lights or groups entities are created."""65 data = {}66 await setup_bridge(hass, data)67 assert len(hass.data[deconz.DATA_DECONZ_ID]) == 068 assert len(hass.states.async_all()) == 069async def test_lights_and_groups(hass):70 """Test that lights or groups entities are created."""71 await setup_bridge(hass, {"lights": LIGHT, "groups": GROUP})72 assert "light.light_1_name" in hass.data[deconz.DATA_DECONZ_ID]73 assert "light.group_1_name" in hass.data[deconz.DATA_DECONZ_ID]74 assert "light.group_2_name" not in hass.data[deconz.DATA_DECONZ_ID]75 assert len(hass.states.async_all()) == 376async def test_add_new_light(hass):77 """Test successful creation of light entities."""78 data = {}79 await setup_bridge(hass, data)80 light = Mock()81 light.name = 'name'82 light.register_async_callback = Mock()83 async_dispatcher_send(hass, 'deconz_new_light', [light])84 await hass.async_block_till_done()85 assert "light.name" in hass.data[deconz.DATA_DECONZ_ID]86async def test_add_new_group(hass):87 """Test successful creation of group entities."""88 data = {}89 await setup_bridge(hass, data)90 group = Mock()91 group.name = 'name'92 group.register_async_callback = Mock()93 async_dispatcher_send(hass, 'deconz_new_group', [group])94 await hass.async_block_till_done()95 assert "light.name" in hass.data[deconz.DATA_DECONZ_ID]96async def test_do_not_add_deconz_groups(hass):97 """Test that clip sensors can be ignored."""98 data = {}99 await setup_bridge(hass, data, allow_deconz_groups=False)100 group = Mock()101 group.name = 'name'102 group.register_async_callback = Mock()103 async_dispatcher_send(hass, 'deconz_new_group', [group])104 await hass.async_block_till_done()105 assert len(hass.data[deconz.DATA_DECONZ_ID]) == 0106async def test_no_switch(hass):107 """Test that a switch doesn't get created as a light entity."""108 await setup_bridge(hass, {"lights": SWITCH})109 assert len(hass.data[deconz.DATA_DECONZ_ID]) == 0...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful