How to use get_device method in autotest

Best Python code snippet using autotest_python

test_sensor.py

Source:test_sensor.py Github

copy

Full Screen

...6 """Test get_device returns None."""7 node = MockNode()8 value = MockValue(data=0, node=node)9 values = MockEntityValues(primary=value)10 device = sensor.get_device(node=node, values=values, node_config={})11 assert device is None12def test_get_device_detects_alarmsensor(mock_openzwave):13 """Test get_device returns a Z-Wave alarmsensor."""14 node = MockNode(15 command_classes=[const.COMMAND_CLASS_ALARM, const.COMMAND_CLASS_SENSOR_ALARM]16 )17 value = MockValue(data=0, node=node)18 values = MockEntityValues(primary=value)19 device = sensor.get_device(node=node, values=values, node_config={})20 assert isinstance(device, sensor.ZWaveAlarmSensor)21def test_get_device_detects_multilevelsensor(mock_openzwave):22 """Test get_device returns a Z-Wave multilevel sensor."""23 node = MockNode(24 command_classes=[25 const.COMMAND_CLASS_SENSOR_MULTILEVEL,26 const.COMMAND_CLASS_METER,27 ]28 )29 value = MockValue(data=0, node=node)30 values = MockEntityValues(primary=value)31 device = sensor.get_device(node=node, values=values, node_config={})32 assert isinstance(device, sensor.ZWaveMultilevelSensor)33 assert device.force_update34def test_get_device_detects_multilevel_meter(mock_openzwave):35 """Test get_device returns a Z-Wave multilevel sensor."""36 node = MockNode(command_classes=[const.COMMAND_CLASS_METER])37 value = MockValue(data=0, node=node, type=const.TYPE_DECIMAL)38 values = MockEntityValues(primary=value)39 device = sensor.get_device(node=node, values=values, node_config={})40 assert isinstance(device, sensor.ZWaveMultilevelSensor)41def test_get_device_detects_battery_sensor(mock_openzwave):42 """Test get_device returns a Z-Wave battery sensor."""43 node = MockNode(command_classes=[const.COMMAND_CLASS_BATTERY])44 value = MockValue(45 data=0,46 node=node,47 type=const.TYPE_DECIMAL,48 command_class=const.COMMAND_CLASS_BATTERY,49 )50 values = MockEntityValues(primary=value)51 device = sensor.get_device(node=node, values=values, node_config={})52 assert isinstance(device, sensor.ZWaveBatterySensor)53 assert device.device_class == openpeerpower.const.DEVICE_CLASS_BATTERY54def test_multilevelsensor_value_changed_temp_fahrenheit(mock_openzwave):55 """Test value changed for Z-Wave multilevel sensor for temperature."""56 node = MockNode(57 command_classes=[58 const.COMMAND_CLASS_SENSOR_MULTILEVEL,59 const.COMMAND_CLASS_METER,60 ]61 )62 value = MockValue(data=190.95555, units="F", node=node)63 values = MockEntityValues(primary=value)64 device = sensor.get_device(node=node, values=values, node_config={})65 assert device.state == 191.066 assert device.unit_of_measurement == openpeerpower.const.TEMP_FAHRENHEIT67 value.data = 197.9555568 value_changed(value)69 assert device.state == 198.070def test_multilevelsensor_value_changed_temp_celsius(mock_openzwave):71 """Test value changed for Z-Wave multilevel sensor for temperature."""72 node = MockNode(73 command_classes=[74 const.COMMAND_CLASS_SENSOR_MULTILEVEL,75 const.COMMAND_CLASS_METER,76 ]77 )78 value = MockValue(data=38.85555, units="C", node=node)79 values = MockEntityValues(primary=value)80 device = sensor.get_device(node=node, values=values, node_config={})81 assert device.state == 38.982 assert device.unit_of_measurement == openpeerpower.const.TEMP_CELSIUS83 value.data = 37.9555584 value_changed(value)85 assert device.state == 38.086def test_multilevelsensor_value_changed_other_units(mock_openzwave):87 """Test value changed for Z-Wave multilevel sensor for other units."""88 node = MockNode(89 command_classes=[90 const.COMMAND_CLASS_SENSOR_MULTILEVEL,91 const.COMMAND_CLASS_METER,92 ]93 )94 value = MockValue(data=190.95555, units="kWh", node=node)95 values = MockEntityValues(primary=value)96 device = sensor.get_device(node=node, values=values, node_config={})97 assert device.state == 190.9698 assert device.unit_of_measurement == "kWh"99 value.data = 197.95555100 value_changed(value)101 assert device.state == 197.96102def test_multilevelsensor_value_changed_integer(mock_openzwave):103 """Test value changed for Z-Wave multilevel sensor for other units."""104 node = MockNode(105 command_classes=[106 const.COMMAND_CLASS_SENSOR_MULTILEVEL,107 const.COMMAND_CLASS_METER,108 ]109 )110 value = MockValue(data=5, units="counts", node=node)111 values = MockEntityValues(primary=value)112 device = sensor.get_device(node=node, values=values, node_config={})113 assert device.state == 5114 assert device.unit_of_measurement == "counts"115 value.data = 6116 value_changed(value)117 assert device.state == 6118def test_alarm_sensor_value_changed(mock_openzwave):119 """Test value changed for Z-Wave sensor."""120 node = MockNode(121 command_classes=[const.COMMAND_CLASS_ALARM, const.COMMAND_CLASS_SENSOR_ALARM]122 )123 value = MockValue(data=12.34, node=node, units="%")124 values = MockEntityValues(primary=value)125 device = sensor.get_device(node=node, values=values, node_config={})126 assert device.state == 12.34127 assert device.unit_of_measurement == "%"128 value.data = 45.67129 value_changed(value)...

Full Screen

Full Screen

test_device_collection.py

Source:test_device_collection.py Github

copy

Full Screen

...70 assert get_device_types(device_collection.get_devices('light1')) == (RGBLight, )71 assert get_device_types(device_collection.get_devices('numbers')) == (RGBLight, RGBLight)72 assert get_device_types(device_collection.get_devices('all')) == (RGBLight, RGBLight, RGBLight)73def test_device_collection_copy(device_collection):74 device_collection.get_device('rgb_light').red = 0.175 device_collection.get_device('rgb_strip_light_3').red = 0.276 device_collection.get_device('rgb_effect_light').x = 0.377 device_collection_2 = copy(device_collection)78 device_collection.get_device('rgb_light').red = 0.479 device_collection.get_device('rgb_strip_light_3').red = 0.580 device_collection.get_device('rgb_effect_light').x = 0.681 assert device_collection_2.get_device('rgb_light').red == 0.182 assert device_collection_2.get_device('rgb_strip_light_3').lights[2].red == 0.283 assert device_collection_2.get_device('rgb_effect_light').x == 0.384def test_device_collection_overlay(device_collection):85 device_collection_2 = copy(device_collection)86 device_collection.get_device('rgb_light').red = 0.187 device_collection.get_device('rgb_strip_light_3').red = 0.588 device_collection.get_device('rgb_effect_light').x = 0.389 device_collection_2.get_device('rgb_light').red = 0.490 device_collection_2.get_device('rgb_strip_light_3').red = 0.291 device_collection_2.get_device('rgb_effect_light').x = 0.692 device_collection &= device_collection_293 assert device_collection.get_device('rgb_light').red == 0.494 assert device_collection.get_device('rgb_strip_light_3').red == 0.595 isclose(device_collection.get_device('rgb_effect_light').x, 0.45)96def test_device_collection_get_devices_should_protect_against_duplicates(device_collection):97 """98 Order of devices should be preserved, but duplicates should be removed99 """100 assert device_collection.get_devices('rgb_light') == device_collection.get_devices('rgb_light', 'rgb_light')101 assert device_collection.get_devices('rgb_light', 'rgb_strip_light_3') == device_collection.get_devices('rgb_light', 'rgb_strip_light_3', 'rgb_light')102 assert device_collection.get_devices('rgb_strip_light_3', 'rgb_light') == device_collection.get_devices('rgb_strip_light_3', 'rgb_light', 'rgb_strip_light_3', 'rgb_strip_light_3')103 all_devices = device_collection.get_devices('rgb_light', 'rgb_strip_light_3', 'rgb_strip_light_8', 'rgb_effect_light')...

Full Screen

Full Screen

test_zwave.py

Source:test_zwave.py Github

copy

Full Screen

...8 """Test get_device returns None."""9 node = MockNode()10 value = MockValue(data=0, node=node)11 values = MockEntityValues(primary=value)12 device = zwave.get_device(node=node, values=values, node_config={})13 assert device is None14def test_get_device_detects_alarmsensor(mock_openzwave):15 """Test get_device returns a Z-Wave alarmsensor."""16 node = MockNode(command_classes=[const.COMMAND_CLASS_ALARM,17 const.COMMAND_CLASS_SENSOR_ALARM])18 value = MockValue(data=0, node=node)19 values = MockEntityValues(primary=value)20 device = zwave.get_device(node=node, values=values, node_config={})21 assert isinstance(device, zwave.ZWaveAlarmSensor)22def test_get_device_detects_multilevelsensor(mock_openzwave):23 """Test get_device returns a Z-Wave multilevel sensor."""24 node = MockNode(command_classes=[const.COMMAND_CLASS_SENSOR_MULTILEVEL,25 const.COMMAND_CLASS_METER])26 value = MockValue(data=0, node=node)27 values = MockEntityValues(primary=value)28 device = zwave.get_device(node=node, values=values, node_config={})29 assert isinstance(device, zwave.ZWaveMultilevelSensor)30 assert device.force_update31def test_get_device_detects_multilevel_meter(mock_openzwave):32 """Test get_device returns a Z-Wave multilevel sensor."""33 node = MockNode(command_classes=[const.COMMAND_CLASS_METER])34 value = MockValue(data=0, node=node, type=const.TYPE_DECIMAL)35 values = MockEntityValues(primary=value)36 device = zwave.get_device(node=node, values=values, node_config={})37 assert isinstance(device, zwave.ZWaveMultilevelSensor)38def test_multilevelsensor_value_changed_temp_fahrenheit(mock_openzwave):39 """Test value changed for Z-Wave multilevel sensor for temperature."""40 node = MockNode(command_classes=[const.COMMAND_CLASS_SENSOR_MULTILEVEL,41 const.COMMAND_CLASS_METER])42 value = MockValue(data=190.95555, units='F', node=node)43 values = MockEntityValues(primary=value)44 device = zwave.get_device(node=node, values=values, node_config={})45 assert device.state == 191.046 assert device.unit_of_measurement == homeassistant.const.TEMP_FAHRENHEIT47 value.data = 197.9555548 value_changed(value)49 assert device.state == 198.050def test_multilevelsensor_value_changed_temp_celsius(mock_openzwave):51 """Test value changed for Z-Wave multilevel sensor for temperature."""52 node = MockNode(command_classes=[const.COMMAND_CLASS_SENSOR_MULTILEVEL,53 const.COMMAND_CLASS_METER])54 value = MockValue(data=38.85555, units='C', node=node)55 values = MockEntityValues(primary=value)56 device = zwave.get_device(node=node, values=values, node_config={})57 assert device.state == 38.958 assert device.unit_of_measurement == homeassistant.const.TEMP_CELSIUS59 value.data = 37.9555560 value_changed(value)61 assert device.state == 38.062def test_multilevelsensor_value_changed_other_units(mock_openzwave):63 """Test value changed for Z-Wave multilevel sensor for other units."""64 node = MockNode(command_classes=[const.COMMAND_CLASS_SENSOR_MULTILEVEL,65 const.COMMAND_CLASS_METER])66 value = MockValue(data=190.95555, units='kWh', node=node)67 values = MockEntityValues(primary=value)68 device = zwave.get_device(node=node, values=values, node_config={})69 assert device.state == 190.9670 assert device.unit_of_measurement == 'kWh'71 value.data = 197.9555572 value_changed(value)73 assert device.state == 197.9674def test_multilevelsensor_value_changed_integer(mock_openzwave):75 """Test value changed for Z-Wave multilevel sensor for other units."""76 node = MockNode(command_classes=[const.COMMAND_CLASS_SENSOR_MULTILEVEL,77 const.COMMAND_CLASS_METER])78 value = MockValue(data=5, units='counts', node=node)79 values = MockEntityValues(primary=value)80 device = zwave.get_device(node=node, values=values, node_config={})81 assert device.state == 582 assert device.unit_of_measurement == 'counts'83 value.data = 684 value_changed(value)85 assert device.state == 686def test_alarm_sensor_value_changed(mock_openzwave):87 """Test value changed for Z-Wave sensor."""88 node = MockNode(command_classes=[const.COMMAND_CLASS_ALARM,89 const.COMMAND_CLASS_SENSOR_ALARM])90 value = MockValue(data=12.34, node=node, units='%')91 values = MockEntityValues(primary=value)92 device = zwave.get_device(node=node, values=values, node_config={})93 assert device.state == 12.3494 assert device.unit_of_measurement == '%'95 value.data = 45.6796 value_changed(value)...

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 autotest 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