def test_setup_component(self): """Test setup component with devices.""" def _add_device(devices): assert len(devices) == 1 assert devices[0].name == "Device_name" device = _get_device_on() self.hass.data[dyson.DYSON_DEVICES] = [device] dyson.setup_platform(self.hass, None, _add_device)
def test_service_set_night_mode(self): """Test set night mode service.""" dyson_device = mock.MagicMock() self.hass.data[DYSON_DEVICES] = [] dyson_device.entity_id = 'fan.living_room' self.hass.data[dyson.DYSON_FAN_DEVICES] = [dyson_device] dyson.setup_platform(self.hass, None, mock.MagicMock()) self.hass.services.call(dyson.DOMAIN, dyson.SERVICE_SET_NIGHT_MODE, {"entity_id": "fan.bed_room", "night_mode": True}, True) assert not dyson_device.night_mode.called self.hass.services.call(dyson.DOMAIN, dyson.SERVICE_SET_NIGHT_MODE, {"entity_id": "fan.living_room", "night_mode": True}, True) dyson_device.night_mode.assert_called_with(True)
def test_setup_component_with_no_devices(self): """Test setup component with no devices.""" self.hass.data[dyson.DYSON_DEVICES] = [] add_devices = mock.MagicMock() dyson.setup_platform(self.hass, None, add_devices) add_devices.assert_called_with([])