Ejemplo n.º 1
0
    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(),
                             mock.MagicMock())

        self.hass.services.call(
            dyson.DYSON_DOMAIN,
            dyson.SERVICE_SET_NIGHT_MODE,
            {
                "entity_id": "fan.bed_room",
                "night_mode": True
            },
            True,
        )
        assert dyson_device.set_night_mode.call_count == 0

        self.hass.services.call(
            dyson.DYSON_DOMAIN,
            dyson.SERVICE_SET_NIGHT_MODE,
            {
                "entity_id": "fan.living_room",
                "night_mode": True
            },
            True,
        )
        dyson_device.set_night_mode.assert_called_with(True)
Ejemplo n.º 2
0
    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_fan = _get_device_on()
        device_non_fan = _get_device_off()

        self.hass.data[dyson.DYSON_DEVICES] = [device_fan, device_non_fan]
        dyson.setup_platform(self.hass, None, _add_device)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
 def test_setup_component_with_no_devices(self):
     """Test setup component with no devices."""
     self.hass.data[dyson.DYSON_DEVICES] = []
     add_entities = mock.MagicMock()
     dyson.setup_platform(self.hass, None, add_entities, mock.Mock())
     add_entities.assert_called_with([])
Ejemplo n.º 5
0
 def test_setup_component_with_no_devices(self):
     """Test setup component with no devices."""
     self.hass.data[dyson.DYSON_DEVICES] = []
     add_entities = mock.MagicMock()
     dyson.setup_platform(self.hass, None, add_entities)
     add_entities.assert_called_with([])