def test_apply_attribute_update_child_status(): """Tests the apply_attribute_update method to a child status.""" # Arrange data = get_json('device_status.json') status = DeviceStatus(None, DEVICE_ID, data) # Act status.apply_attribute_update( 'bottomButton', 'switchLevel', 'level', 50) # Assert assert status.components['bottomButton'].level == 50
def test_apply_attribute_update_preserve_unit(): """Tests the apply_attribute_update preserves the old unit.""" # Arrange data = get_json('device_status.json') device = DeviceStatus(None, DEVICE_ID, data) device.attributes[Capability.switch_level] = Status(40, '%', None) # Act device.apply_attribute_update( 'main', Capability.switch_level, Attribute.level, 50) # Assert status = device.attributes[Attribute.level] assert status.unit == '%'
def test_apply_attribute_update(): """Tests the apply_attribute_update method.""" # Arrange data = get_json('device_status.json') device = DeviceStatus(None, DEVICE_ID, data) # Act device.apply_attribute_update( 'main', Capability.switch_level, Attribute.level, 50, '%', {'test': 'test'}) # Assert status = device.attributes[Attribute.level] assert status.value == 50 assert status.unit == '%' assert status.data == {'test': 'test'}
def test_apply_attribute_update(): """Tests the apply_attribute_update method.""" # Arrange data = get_json("device_status.json") device = DeviceStatus(None, DEVICE_ID, data) # Act device.apply_attribute_update("main", Capability.switch_level, Attribute.level, 50, "%", {"test": "test"}) # Assert status = device.attributes[Attribute.level] assert status.value == 50 assert status.unit == "%" assert status.data == {"test": "test"}