Beispiel #1
0
 def test_dyson_heat_on(self):
     """Test turn on heat."""
     device = _get_device_heat_on()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     entity.set_hvac_mode(dyson.HVAC_MODE_HEAT)
     set_config = device.set_configuration
     set_config.assert_called_with(heat_mode=HeatMode.HEAT_ON)
Beispiel #2
0
 def test_on_message(self):
     """Test when message is received."""
     device = _get_device_heat_on()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     entity.schedule_update_ha_state = mock.Mock()
     entity.on_message(MockDysonState())
     entity.schedule_update_ha_state.assert_called_with()
Beispiel #3
0
 def test_dyson_fan_modes(self):
     """Test get fan list."""
     device = _get_device_heat_on()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     assert len(entity.fan_modes) == 2
     assert dyson.FAN_FOCUS in entity.fan_modes
     assert dyson.FAN_DIFFUSE in entity.fan_modes
Beispiel #4
0
    def test_dyson_set_temperature(self):
        """Test set climate temperature."""
        device = _get_device_heat_on()
        device.temp_unit = TEMP_CELSIUS
        entity = dyson.DysonPureHotCoolLinkDevice(device)
        assert not entity.should_poll

        # Without target temp.
        kwargs = {}
        entity.set_temperature(**kwargs)
        set_config = device.set_configuration
        set_config.assert_not_called()

        kwargs = {ATTR_TEMPERATURE: 23}
        entity.set_temperature(**kwargs)
        set_config = device.set_configuration
        set_config.assert_called_with(
            heat_mode=HeatMode.HEAT_ON, heat_target=HeatTarget.celsius(23)
        )

        # Should clip the target temperature between 1 and 37 inclusive.
        kwargs = {ATTR_TEMPERATURE: 50}
        entity.set_temperature(**kwargs)
        set_config = device.set_configuration
        set_config.assert_called_with(
            heat_mode=HeatMode.HEAT_ON, heat_target=HeatTarget.celsius(37)
        )

        kwargs = {ATTR_TEMPERATURE: -5}
        entity.set_temperature(**kwargs)
        set_config = device.set_configuration
        set_config.assert_called_with(
            heat_mode=HeatMode.HEAT_ON, heat_target=HeatTarget.celsius(1)
        )
Beispiel #5
0
 def test_general_properties(self):
     """Test properties of entity."""
     device = _get_device_with_no_state()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     assert entity.should_poll is False
     assert entity.supported_features == dyson.SUPPORT_FLAGS
     assert entity.temperature_unit == TEMP_CELSIUS
Beispiel #6
0
 def test_dyson_heat_off(self):
     """Test turn off heat."""
     device = _get_device_heat_off()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     entity.set_operation_mode(dyson.STATE_COOL)
     set_config = device.set_configuration
     set_config.assert_called_with(heat_mode=HeatMode.HEAT_OFF)
Beispiel #7
0
 def test_dyson_operation_list(self):
     """Test get operation list."""
     device = _get_device_heat_on()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     assert len(entity.operation_list) == 2
     assert dyson.STATE_HEAT in entity.operation_list
     assert dyson.STATE_COOL in entity.operation_list
Beispiel #8
0
 def test_dyson_operation_list(self):
     """Test get operation list."""
     device = _get_device_heat_on()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     assert len(entity.hvac_modes) == 2
     assert dyson.HVAC_MODE_HEAT in entity.hvac_modes
     assert dyson.HVAC_MODE_COOL in entity.hvac_modes
Beispiel #9
0
    def test_dyson_set_temperature_when_cooling_mode(self):
        """Test set climate temperature when heating is off."""
        device = _get_device_cool()
        device.temp_unit = TEMP_CELSIUS
        entity = dyson.DysonPureHotCoolLinkDevice(device)
        entity.schedule_update_ha_state = mock.Mock()

        kwargs = {ATTR_TEMPERATURE: 23}
        entity.set_temperature(**kwargs)
        set_config = device.set_configuration
        set_config.assert_called_with(heat_mode=HeatMode.HEAT_ON,
                                      heat_target=HeatTarget.celsius(23))
Beispiel #10
0
    def test_dyson_set_fan_mode(self):
        """Test set fan mode."""
        device = _get_device_heat_on()
        entity = dyson.DysonPureHotCoolLinkDevice(device)
        assert not entity.should_poll

        entity.set_fan_mode(dyson.FAN_FOCUS)
        set_config = device.set_configuration
        set_config.assert_called_with(focus_mode=FocusMode.FOCUS_ON)

        entity.set_fan_mode(dyson.FAN_DIFFUSE)
        set_config = device.set_configuration
        set_config.assert_called_with(focus_mode=FocusMode.FOCUS_OFF)
Beispiel #11
0
    def test_dyson_set_hvac_mode(self):
        """Test set operation mode."""
        device = _get_device_heat_on()
        entity = dyson.DysonPureHotCoolLinkDevice(device)
        assert not entity.should_poll

        entity.set_hvac_mode(dyson.HVAC_MODE_HEAT)
        set_config = device.set_configuration
        set_config.assert_called_with(heat_mode=HeatMode.HEAT_ON)

        entity.set_hvac_mode(dyson.HVAC_MODE_COOL)
        set_config = device.set_configuration
        set_config.assert_called_with(heat_mode=HeatMode.HEAT_OFF)
Beispiel #12
0
 def test_property_target_temperature(self):
     """Test properties of target temperature."""
     device = _get_device_heat_on()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     assert entity.target_temperature == 23
Beispiel #13
0
 def test_property_current_temperature(self):
     """Test properties of current temperature."""
     device = _get_device_heat_on()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     # Result should be in celsius, hence then subtraction of 273.
     assert entity.current_temperature == 289 - 273
Beispiel #14
0
 def test_property_current_humidity_without_env_state(self):
     """Test properties of current humidity without env state."""
     device = _get_device_with_no_state()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     assert entity.current_humidity is None
Beispiel #15
0
 def test_property_current_humidity_with_invalid_env_state(self):
     """Test properties of current humidity with invalid env state."""
     device = _get_device_off()
     device.environmental_state.humidity = 0
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     assert entity.current_humidity is None
Beispiel #16
0
 def test_property_current_humidity(self):
     """Test properties of current humidity."""
     device = _get_device_heat_on()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     assert entity.current_humidity == 53
Beispiel #17
0
 def test_dyson_heat_value_idle(self):
     """Test get heat value idle."""
     device = _get_device_heat_off()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     assert entity.current_operation == dyson.STATE_IDLE
Beispiel #18
0
 def test_dyson_heat_value_idle(self):
     """Test get heat value idle."""
     device = _get_device_heat_off()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     assert entity.hvac_mode == dyson.HVAC_MODE_HEAT
     assert entity.hvac_action == dyson.CURRENT_HVAC_IDLE
Beispiel #19
0
 def test_dyson_heat_value_off(self):
     """Test get heat value off."""
     device = _get_device_cool()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     assert entity.hvac_mode == dyson.HVAC_MODE_COOL
Beispiel #20
0
 def test_dyson_fan_mode_focus(self):
     """Test fan focus mode."""
     device = _get_device_focus()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     assert entity.fan_mode == dyson.FAN_FOCUS
Beispiel #21
0
 def test_dyson_fan_mode_diffuse(self):
     """Test fan diffuse mode."""
     device = _get_device_diffuse()
     entity = dyson.DysonPureHotCoolLinkDevice(device)
     assert entity.fan_mode == dyson.FAN_DIFFUSE