Pytest tests (#17750)
* Convert core tests
* Convert component tests to use pytest assert
* Lint 🤷♂️
* Fix test
* Fix 3 typos in docs
This commit is contained in:
1 parent
4222f7562b
commit
08fe7c3ece
223 files changed
+6747
-7237
No files matched your search
@@ -23,10 +23,10 @@ class TestDemoClimate(unittest.TestCase):
|
||||
"""Set up things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
self.hass.config.units = METRIC_SYSTEM
|
||||
self.assertTrue(setup_component(self.hass, climate.DOMAIN, {
|
||||
assert setup_component(self.hass, climate.DOMAIN, {
|
||||
'climate': {
|
||||
'platform': 'demo',
|
||||
}}))
|
||||
}})
|
||||
|
||||
def tearDown(self): # pylint: disable=invalid-name
|
||||
"""Stop down everything that was started."""
|
||||
@@ -35,132 +35,132 @@ class TestDemoClimate(unittest.TestCase):
|
||||
def test_setup_params(self):
|
||||
"""Test the initial parameters."""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(21, state.attributes.get('temperature'))
|
||||
self.assertEqual('on', state.attributes.get('away_mode'))
|
||||
self.assertEqual(22, state.attributes.get('current_temperature'))
|
||||
self.assertEqual("On High", state.attributes.get('fan_mode'))
|
||||
self.assertEqual(67, state.attributes.get('humidity'))
|
||||
self.assertEqual(54, state.attributes.get('current_humidity'))
|
||||
self.assertEqual("Off", state.attributes.get('swing_mode'))
|
||||
self.assertEqual("cool", state.attributes.get('operation_mode'))
|
||||
self.assertEqual('off', state.attributes.get('aux_heat'))
|
||||
assert 21 == state.attributes.get('temperature')
|
||||
assert 'on' == state.attributes.get('away_mode')
|
||||
assert 22 == state.attributes.get('current_temperature')
|
||||
assert "On High" == state.attributes.get('fan_mode')
|
||||
assert 67 == state.attributes.get('humidity')
|
||||
assert 54 == state.attributes.get('current_humidity')
|
||||
assert "Off" == state.attributes.get('swing_mode')
|
||||
assert "cool" == state.attributes.get('operation_mode')
|
||||
assert 'off' == state.attributes.get('aux_heat')
|
||||
|
||||
def test_default_setup_params(self):
|
||||
"""Test the setup with default parameters."""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(7, state.attributes.get('min_temp'))
|
||||
self.assertEqual(35, state.attributes.get('max_temp'))
|
||||
self.assertEqual(30, state.attributes.get('min_humidity'))
|
||||
self.assertEqual(99, state.attributes.get('max_humidity'))
|
||||
assert 7 == state.attributes.get('min_temp')
|
||||
assert 35 == state.attributes.get('max_temp')
|
||||
assert 30 == state.attributes.get('min_humidity')
|
||||
assert 99 == state.attributes.get('max_humidity')
|
||||
|
||||
def test_set_only_target_temp_bad_attr(self):
|
||||
"""Test setting the target temperature without required attribute."""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(21, state.attributes.get('temperature'))
|
||||
assert 21 == state.attributes.get('temperature')
|
||||
common.set_temperature(self.hass, None, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(21, state.attributes.get('temperature'))
|
||||
assert 21 == state.attributes.get('temperature')
|
||||
|
||||
def test_set_only_target_temp(self):
|
||||
"""Test the setting of the target temperature."""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(21, state.attributes.get('temperature'))
|
||||
assert 21 == state.attributes.get('temperature')
|
||||
common.set_temperature(self.hass, 30, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(30.0, state.attributes.get('temperature'))
|
||||
assert 30.0 == state.attributes.get('temperature')
|
||||
|
||||
def test_set_only_target_temp_with_convert(self):
|
||||
"""Test the setting of the target temperature."""
|
||||
state = self.hass.states.get(ENTITY_HEATPUMP)
|
||||
self.assertEqual(20, state.attributes.get('temperature'))
|
||||
assert 20 == state.attributes.get('temperature')
|
||||
common.set_temperature(self.hass, 21, ENTITY_HEATPUMP)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_HEATPUMP)
|
||||
self.assertEqual(21.0, state.attributes.get('temperature'))
|
||||
assert 21.0 == state.attributes.get('temperature')
|
||||
|
||||
def test_set_target_temp_range(self):
|
||||
"""Test the setting of the target temperature with range."""
|
||||
state = self.hass.states.get(ENTITY_ECOBEE)
|
||||
self.assertEqual(None, state.attributes.get('temperature'))
|
||||
self.assertEqual(21.0, state.attributes.get('target_temp_low'))
|
||||
self.assertEqual(24.0, state.attributes.get('target_temp_high'))
|
||||
assert state.attributes.get('temperature') is None
|
||||
assert 21.0 == state.attributes.get('target_temp_low')
|
||||
assert 24.0 == state.attributes.get('target_temp_high')
|
||||
common.set_temperature(self.hass, target_temp_high=25,
|
||||
target_temp_low=20, entity_id=ENTITY_ECOBEE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_ECOBEE)
|
||||
self.assertEqual(None, state.attributes.get('temperature'))
|
||||
self.assertEqual(20.0, state.attributes.get('target_temp_low'))
|
||||
self.assertEqual(25.0, state.attributes.get('target_temp_high'))
|
||||
assert state.attributes.get('temperature') is None
|
||||
assert 20.0 == state.attributes.get('target_temp_low')
|
||||
assert 25.0 == state.attributes.get('target_temp_high')
|
||||
|
||||
def test_set_target_temp_range_bad_attr(self):
|
||||
"""Test setting the target temperature range without attribute."""
|
||||
state = self.hass.states.get(ENTITY_ECOBEE)
|
||||
self.assertEqual(None, state.attributes.get('temperature'))
|
||||
self.assertEqual(21.0, state.attributes.get('target_temp_low'))
|
||||
self.assertEqual(24.0, state.attributes.get('target_temp_high'))
|
||||
assert state.attributes.get('temperature') is None
|
||||
assert 21.0 == state.attributes.get('target_temp_low')
|
||||
assert 24.0 == state.attributes.get('target_temp_high')
|
||||
common.set_temperature(self.hass, temperature=None,
|
||||
entity_id=ENTITY_ECOBEE, target_temp_low=None,
|
||||
target_temp_high=None)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_ECOBEE)
|
||||
self.assertEqual(None, state.attributes.get('temperature'))
|
||||
self.assertEqual(21.0, state.attributes.get('target_temp_low'))
|
||||
self.assertEqual(24.0, state.attributes.get('target_temp_high'))
|
||||
assert state.attributes.get('temperature') is None
|
||||
assert 21.0 == state.attributes.get('target_temp_low')
|
||||
assert 24.0 == state.attributes.get('target_temp_high')
|
||||
|
||||
def test_set_target_humidity_bad_attr(self):
|
||||
"""Test setting the target humidity without required attribute."""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(67, state.attributes.get('humidity'))
|
||||
assert 67 == state.attributes.get('humidity')
|
||||
common.set_humidity(self.hass, None, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(67, state.attributes.get('humidity'))
|
||||
assert 67 == state.attributes.get('humidity')
|
||||
|
||||
def test_set_target_humidity(self):
|
||||
"""Test the setting of the target humidity."""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(67, state.attributes.get('humidity'))
|
||||
assert 67 == state.attributes.get('humidity')
|
||||
common.set_humidity(self.hass, 64, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(64.0, state.attributes.get('humidity'))
|
||||
assert 64.0 == state.attributes.get('humidity')
|
||||
|
||||
def test_set_fan_mode_bad_attr(self):
|
||||
"""Test setting fan mode without required attribute."""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("On High", state.attributes.get('fan_mode'))
|
||||
assert "On High" == state.attributes.get('fan_mode')
|
||||
common.set_fan_mode(self.hass, None, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("On High", state.attributes.get('fan_mode'))
|
||||
assert "On High" == state.attributes.get('fan_mode')
|
||||
|
||||
def test_set_fan_mode(self):
|
||||
"""Test setting of new fan mode."""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("On High", state.attributes.get('fan_mode'))
|
||||
assert "On High" == state.attributes.get('fan_mode')
|
||||
common.set_fan_mode(self.hass, "On Low", ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("On Low", state.attributes.get('fan_mode'))
|
||||
assert "On Low" == state.attributes.get('fan_mode')
|
||||
|
||||
def test_set_swing_mode_bad_attr(self):
|
||||
"""Test setting swing mode without required attribute."""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("Off", state.attributes.get('swing_mode'))
|
||||
assert "Off" == state.attributes.get('swing_mode')
|
||||
common.set_swing_mode(self.hass, None, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("Off", state.attributes.get('swing_mode'))
|
||||
assert "Off" == state.attributes.get('swing_mode')
|
||||
|
||||
def test_set_swing(self):
|
||||
"""Test setting of new swing mode."""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("Off", state.attributes.get('swing_mode'))
|
||||
assert "Off" == state.attributes.get('swing_mode')
|
||||
common.set_swing_mode(self.hass, "Auto", ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("Auto", state.attributes.get('swing_mode'))
|
||||
assert "Auto" == state.attributes.get('swing_mode')
|
||||
|
||||
def test_set_operation_bad_attr_and_state(self):
|
||||
"""Test setting operation mode without required attribute.
|
||||
@@ -168,103 +168,103 @@ class TestDemoClimate(unittest.TestCase):
|
||||
Also check the state.
|
||||
"""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("cool", state.attributes.get('operation_mode'))
|
||||
self.assertEqual("cool", state.state)
|
||||
assert "cool" == state.attributes.get('operation_mode')
|
||||
assert "cool" == state.state
|
||||
common.set_operation_mode(self.hass, None, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("cool", state.attributes.get('operation_mode'))
|
||||
self.assertEqual("cool", state.state)
|
||||
assert "cool" == state.attributes.get('operation_mode')
|
||||
assert "cool" == state.state
|
||||
|
||||
def test_set_operation(self):
|
||||
"""Test setting of new operation mode."""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("cool", state.attributes.get('operation_mode'))
|
||||
self.assertEqual("cool", state.state)
|
||||
assert "cool" == state.attributes.get('operation_mode')
|
||||
assert "cool" == state.state
|
||||
common.set_operation_mode(self.hass, "heat", ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("heat", state.attributes.get('operation_mode'))
|
||||
self.assertEqual("heat", state.state)
|
||||
assert "heat" == state.attributes.get('operation_mode')
|
||||
assert "heat" == state.state
|
||||
|
||||
def test_set_away_mode_bad_attr(self):
|
||||
"""Test setting the away mode without required attribute."""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('on', state.attributes.get('away_mode'))
|
||||
assert 'on' == state.attributes.get('away_mode')
|
||||
common.set_away_mode(self.hass, None, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual('on', state.attributes.get('away_mode'))
|
||||
assert 'on' == state.attributes.get('away_mode')
|
||||
|
||||
def test_set_away_mode_on(self):
|
||||
"""Test setting the away mode on/true."""
|
||||
common.set_away_mode(self.hass, True, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('on', state.attributes.get('away_mode'))
|
||||
assert 'on' == state.attributes.get('away_mode')
|
||||
|
||||
def test_set_away_mode_off(self):
|
||||
"""Test setting the away mode off/false."""
|
||||
common.set_away_mode(self.hass, False, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('away_mode'))
|
||||
assert 'off' == state.attributes.get('away_mode')
|
||||
|
||||
def test_set_hold_mode_home(self):
|
||||
"""Test setting the hold mode home."""
|
||||
common.set_hold_mode(self.hass, 'home', ENTITY_ECOBEE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_ECOBEE)
|
||||
self.assertEqual('home', state.attributes.get('hold_mode'))
|
||||
assert 'home' == state.attributes.get('hold_mode')
|
||||
|
||||
def test_set_hold_mode_away(self):
|
||||
"""Test setting the hold mode away."""
|
||||
common.set_hold_mode(self.hass, 'away', ENTITY_ECOBEE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_ECOBEE)
|
||||
self.assertEqual('away', state.attributes.get('hold_mode'))
|
||||
assert 'away' == state.attributes.get('hold_mode')
|
||||
|
||||
def test_set_hold_mode_none(self):
|
||||
"""Test setting the hold mode off/false."""
|
||||
common.set_hold_mode(self.hass, 'off', ENTITY_ECOBEE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_ECOBEE)
|
||||
self.assertEqual('off', state.attributes.get('hold_mode'))
|
||||
assert 'off' == state.attributes.get('hold_mode')
|
||||
|
||||
def test_set_aux_heat_bad_attr(self):
|
||||
"""Test setting the auxiliary heater without required attribute."""
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('aux_heat'))
|
||||
assert 'off' == state.attributes.get('aux_heat')
|
||||
common.set_aux_heat(self.hass, None, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual('off', state.attributes.get('aux_heat'))
|
||||
assert 'off' == state.attributes.get('aux_heat')
|
||||
|
||||
def test_set_aux_heat_on(self):
|
||||
"""Test setting the axillary heater on/true."""
|
||||
common.set_aux_heat(self.hass, True, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('on', state.attributes.get('aux_heat'))
|
||||
assert 'on' == state.attributes.get('aux_heat')
|
||||
|
||||
def test_set_aux_heat_off(self):
|
||||
"""Test setting the auxiliary heater off/false."""
|
||||
common.set_aux_heat(self.hass, False, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('aux_heat'))
|
||||
assert 'off' == state.attributes.get('aux_heat')
|
||||
|
||||
def test_set_on_off(self):
|
||||
"""Test on/off service."""
|
||||
state = self.hass.states.get(ENTITY_ECOBEE)
|
||||
self.assertEqual('auto', state.state)
|
||||
assert 'auto' == state.state
|
||||
|
||||
self.hass.services.call(climate.DOMAIN, climate.SERVICE_TURN_OFF,
|
||||
{climate.ATTR_ENTITY_ID: ENTITY_ECOBEE})
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_ECOBEE)
|
||||
self.assertEqual('off', state.state)
|
||||
assert 'off' == state.state
|
||||
|
||||
self.hass.services.call(climate.DOMAIN, climate.SERVICE_TURN_ON,
|
||||
{climate.ATTR_ENTITY_ID: ENTITY_ECOBEE})
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_ECOBEE)
|
||||
self.assertEqual('auto', state.state)
|
||||
assert 'auto' == state.state
|
||||
@@ -123,7 +123,7 @@ class DysonTest(unittest.TestCase):
|
||||
dyson_parent.CONF_LANGUAGE: "US",
|
||||
}
|
||||
})
|
||||
self.assertEqual(len(self.hass.data[dyson.DYSON_DEVICES]), 2)
|
||||
assert len(self.hass.data[dyson.DYSON_DEVICES]) == 2
|
||||
self.hass.block_till_done()
|
||||
for m in mocked_devices.return_value:
|
||||
assert m.add_message_listener.called
|
||||
@@ -145,7 +145,7 @@ class DysonTest(unittest.TestCase):
|
||||
self.hass.data[dyson.DYSON_DEVICES] = devices
|
||||
add_devices = mock.MagicMock()
|
||||
dyson.setup_platform(self.hass, None, add_devices, discovery_info={})
|
||||
self.assertTrue(add_devices.called)
|
||||
assert add_devices.called
|
||||
|
||||
def test_setup_component_with_invalid_devices(self):
|
||||
"""Test setup component with invalid devices."""
|
||||
@@ -175,7 +175,7 @@ class DysonTest(unittest.TestCase):
|
||||
device = _get_device_heat_on()
|
||||
device.temp_unit = TEMP_CELSIUS
|
||||
entity = dyson.DysonPureHotCoolLinkDevice(device)
|
||||
self.assertFalse(entity.should_poll)
|
||||
assert not entity.should_poll
|
||||
|
||||
# Without target temp.
|
||||
kwargs = {}
|
||||
@@ -223,7 +223,7 @@ class DysonTest(unittest.TestCase):
|
||||
"""Test set fan mode."""
|
||||
device = _get_device_heat_on()
|
||||
entity = dyson.DysonPureHotCoolLinkDevice(device)
|
||||
self.assertFalse(entity.should_poll)
|
||||
assert not entity.should_poll
|
||||
|
||||
entity.set_fan_mode(dyson.STATE_FOCUS)
|
||||
set_config = device.set_configuration
|
||||
@@ -237,27 +237,27 @@ class DysonTest(unittest.TestCase):
|
||||
"""Test get fan list."""
|
||||
device = _get_device_heat_on()
|
||||
entity = dyson.DysonPureHotCoolLinkDevice(device)
|
||||
self.assertEqual(len(entity.fan_list), 2)
|
||||
self.assertTrue(dyson.STATE_FOCUS in entity.fan_list)
|
||||
self.assertTrue(dyson.STATE_DIFFUSE in entity.fan_list)
|
||||
assert len(entity.fan_list) == 2
|
||||
assert dyson.STATE_FOCUS in entity.fan_list
|
||||
assert dyson.STATE_DIFFUSE in entity.fan_list
|
||||
|
||||
def test_dyson_fan_mode_focus(self):
|
||||
"""Test fan focus mode."""
|
||||
device = _get_device_focus()
|
||||
entity = dyson.DysonPureHotCoolLinkDevice(device)
|
||||
self.assertEqual(entity.current_fan_mode, dyson.STATE_FOCUS)
|
||||
assert entity.current_fan_mode == dyson.STATE_FOCUS
|
||||
|
||||
def test_dyson_fan_mode_diffuse(self):
|
||||
"""Test fan diffuse mode."""
|
||||
device = _get_device_diffuse()
|
||||
entity = dyson.DysonPureHotCoolLinkDevice(device)
|
||||
self.assertEqual(entity.current_fan_mode, dyson.STATE_DIFFUSE)
|
||||
assert entity.current_fan_mode == dyson.STATE_DIFFUSE
|
||||
|
||||
def test_dyson_set_operation_mode(self):
|
||||
"""Test set operation mode."""
|
||||
device = _get_device_heat_on()
|
||||
entity = dyson.DysonPureHotCoolLinkDevice(device)
|
||||
self.assertFalse(entity.should_poll)
|
||||
assert not entity.should_poll
|
||||
|
||||
entity.set_operation_mode(dyson.STATE_HEAT)
|
||||
set_config = device.set_configuration
|
||||
@@ -271,9 +271,9 @@ class DysonTest(unittest.TestCase):
|
||||
"""Test get operation list."""
|
||||
device = _get_device_heat_on()
|
||||
entity = dyson.DysonPureHotCoolLinkDevice(device)
|
||||
self.assertEqual(len(entity.operation_list), 2)
|
||||
self.assertTrue(dyson.STATE_HEAT in entity.operation_list)
|
||||
self.assertTrue(dyson.STATE_COOL in entity.operation_list)
|
||||
assert len(entity.operation_list) == 2
|
||||
assert dyson.STATE_HEAT in entity.operation_list
|
||||
assert dyson.STATE_COOL in entity.operation_list
|
||||
|
||||
def test_dyson_heat_off(self):
|
||||
"""Test turn off heat."""
|
||||
@@ -295,19 +295,19 @@ class DysonTest(unittest.TestCase):
|
||||
"""Test get heat value on."""
|
||||
device = _get_device_heat_on()
|
||||
entity = dyson.DysonPureHotCoolLinkDevice(device)
|
||||
self.assertEqual(entity.current_operation, dyson.STATE_HEAT)
|
||||
assert entity.current_operation == dyson.STATE_HEAT
|
||||
|
||||
def test_dyson_heat_value_off(self):
|
||||
"""Test get heat value off."""
|
||||
device = _get_device_cool()
|
||||
entity = dyson.DysonPureHotCoolLinkDevice(device)
|
||||
self.assertEqual(entity.current_operation, dyson.STATE_COOL)
|
||||
assert entity.current_operation == dyson.STATE_COOL
|
||||
|
||||
def test_dyson_heat_value_idle(self):
|
||||
"""Test get heat value idle."""
|
||||
device = _get_device_heat_off()
|
||||
entity = dyson.DysonPureHotCoolLinkDevice(device)
|
||||
self.assertEqual(entity.current_operation, dyson.STATE_IDLE)
|
||||
assert entity.current_operation == dyson.STATE_IDLE
|
||||
|
||||
def test_on_message(self):
|
||||
"""Test when message is received."""
|
||||
@@ -321,38 +321,38 @@ class DysonTest(unittest.TestCase):
|
||||
"""Test properties of entity."""
|
||||
device = _get_device_with_no_state()
|
||||
entity = dyson.DysonPureHotCoolLinkDevice(device)
|
||||
self.assertEqual(entity.should_poll, False)
|
||||
self.assertEqual(entity.supported_features, dyson.SUPPORT_FLAGS)
|
||||
self.assertEqual(entity.temperature_unit, TEMP_CELSIUS)
|
||||
assert entity.should_poll is False
|
||||
assert entity.supported_features == dyson.SUPPORT_FLAGS
|
||||
assert entity.temperature_unit == TEMP_CELSIUS
|
||||
|
||||
def test_property_current_humidity(self):
|
||||
"""Test properties of current humidity."""
|
||||
device = _get_device_heat_on()
|
||||
entity = dyson.DysonPureHotCoolLinkDevice(device)
|
||||
self.assertEqual(entity.current_humidity, 53)
|
||||
assert entity.current_humidity == 53
|
||||
|
||||
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)
|
||||
self.assertEqual(entity.current_humidity, None)
|
||||
assert entity.current_humidity is None
|
||||
|
||||
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)
|
||||
self.assertEqual(entity.current_humidity, None)
|
||||
assert entity.current_humidity is None
|
||||
|
||||
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.
|
||||
self.assertEqual(entity.current_temperature, 289 - 273)
|
||||
assert entity.current_temperature == 289 - 273
|
||||
|
||||
def test_property_target_temperature(self):
|
||||
"""Test properties of target temperature."""
|
||||
device = _get_device_heat_on()
|
||||
entity = dyson.DysonPureHotCoolLinkDevice(device)
|
||||
self.assertEqual(entity.target_temperature, 23)
|
||||
assert entity.target_temperature == 23
|
||||
@@ -44,214 +44,214 @@ class TestEcobee(unittest.TestCase):
|
||||
|
||||
def test_name(self):
|
||||
"""Test name property."""
|
||||
self.assertEqual('Ecobee', self.thermostat.name)
|
||||
assert 'Ecobee' == self.thermostat.name
|
||||
|
||||
def test_temperature_unit(self):
|
||||
"""Test temperature unit property."""
|
||||
self.assertEqual(const.TEMP_FAHRENHEIT,
|
||||
self.thermostat.temperature_unit)
|
||||
assert const.TEMP_FAHRENHEIT == \
|
||||
self.thermostat.temperature_unit
|
||||
|
||||
def test_current_temperature(self):
|
||||
"""Test current temperature."""
|
||||
self.assertEqual(30, self.thermostat.current_temperature)
|
||||
assert 30 == self.thermostat.current_temperature
|
||||
self.ecobee['runtime']['actualTemperature'] = 404
|
||||
self.assertEqual(40.4, self.thermostat.current_temperature)
|
||||
assert 40.4 == self.thermostat.current_temperature
|
||||
|
||||
def test_target_temperature_low(self):
|
||||
"""Test target low temperature."""
|
||||
self.assertEqual(40, self.thermostat.target_temperature_low)
|
||||
assert 40 == self.thermostat.target_temperature_low
|
||||
self.ecobee['runtime']['desiredHeat'] = 502
|
||||
self.assertEqual(50.2, self.thermostat.target_temperature_low)
|
||||
assert 50.2 == self.thermostat.target_temperature_low
|
||||
|
||||
def test_target_temperature_high(self):
|
||||
"""Test target high temperature."""
|
||||
self.assertEqual(20, self.thermostat.target_temperature_high)
|
||||
assert 20 == self.thermostat.target_temperature_high
|
||||
self.ecobee['runtime']['desiredCool'] = 103
|
||||
self.assertEqual(10.3, self.thermostat.target_temperature_high)
|
||||
assert 10.3 == self.thermostat.target_temperature_high
|
||||
|
||||
def test_target_temperature(self):
|
||||
"""Test target temperature."""
|
||||
self.assertIsNone(self.thermostat.target_temperature)
|
||||
assert self.thermostat.target_temperature is None
|
||||
self.ecobee['settings']['hvacMode'] = 'heat'
|
||||
self.assertEqual(40, self.thermostat.target_temperature)
|
||||
assert 40 == self.thermostat.target_temperature
|
||||
self.ecobee['settings']['hvacMode'] = 'cool'
|
||||
self.assertEqual(20, self.thermostat.target_temperature)
|
||||
assert 20 == self.thermostat.target_temperature
|
||||
self.ecobee['settings']['hvacMode'] = 'auxHeatOnly'
|
||||
self.assertEqual(40, self.thermostat.target_temperature)
|
||||
assert 40 == self.thermostat.target_temperature
|
||||
self.ecobee['settings']['hvacMode'] = 'off'
|
||||
self.assertIsNone(self.thermostat.target_temperature)
|
||||
assert self.thermostat.target_temperature is None
|
||||
|
||||
def test_desired_fan_mode(self):
|
||||
"""Test desired fan mode property."""
|
||||
self.assertEqual('on', self.thermostat.current_fan_mode)
|
||||
assert 'on' == self.thermostat.current_fan_mode
|
||||
self.ecobee['runtime']['desiredFanMode'] = 'auto'
|
||||
self.assertEqual('auto', self.thermostat.current_fan_mode)
|
||||
assert 'auto' == self.thermostat.current_fan_mode
|
||||
|
||||
def test_fan(self):
|
||||
"""Test fan property."""
|
||||
self.assertEqual(const.STATE_ON, self.thermostat.fan)
|
||||
assert const.STATE_ON == self.thermostat.fan
|
||||
self.ecobee['equipmentStatus'] = ''
|
||||
self.assertEqual(STATE_OFF, self.thermostat.fan)
|
||||
assert STATE_OFF == self.thermostat.fan
|
||||
self.ecobee['equipmentStatus'] = 'heatPump, heatPump2'
|
||||
self.assertEqual(STATE_OFF, self.thermostat.fan)
|
||||
assert STATE_OFF == self.thermostat.fan
|
||||
|
||||
def test_current_hold_mode_away_temporary(self):
|
||||
"""Test current hold mode when away."""
|
||||
# Temporary away hold
|
||||
self.assertEqual('away', self.thermostat.current_hold_mode)
|
||||
assert 'away' == self.thermostat.current_hold_mode
|
||||
self.ecobee['events'][0]['endDate'] = '2018-01-01 09:49:00'
|
||||
self.assertEqual('away', self.thermostat.current_hold_mode)
|
||||
assert 'away' == self.thermostat.current_hold_mode
|
||||
|
||||
def test_current_hold_mode_away_permanent(self):
|
||||
"""Test current hold mode when away permanently."""
|
||||
# Permanent away hold
|
||||
self.ecobee['events'][0]['endDate'] = '2019-01-01 10:17:00'
|
||||
self.assertIsNone(self.thermostat.current_hold_mode)
|
||||
assert self.thermostat.current_hold_mode is None
|
||||
|
||||
def test_current_hold_mode_no_running_events(self):
|
||||
"""Test current hold mode when no running events."""
|
||||
# No running events
|
||||
self.ecobee['events'][0]['running'] = False
|
||||
self.assertIsNone(self.thermostat.current_hold_mode)
|
||||
assert self.thermostat.current_hold_mode is None
|
||||
|
||||
def test_current_hold_mode_vacation(self):
|
||||
"""Test current hold mode when on vacation."""
|
||||
# Vacation Hold
|
||||
self.ecobee['events'][0]['type'] = 'vacation'
|
||||
self.assertEqual('vacation', self.thermostat.current_hold_mode)
|
||||
assert 'vacation' == self.thermostat.current_hold_mode
|
||||
|
||||
def test_current_hold_mode_climate(self):
|
||||
"""Test current hold mode when heat climate is set."""
|
||||
# Preset climate hold
|
||||
self.ecobee['events'][0]['type'] = 'hold'
|
||||
self.ecobee['events'][0]['holdClimateRef'] = 'heatClimate'
|
||||
self.assertEqual('heatClimate', self.thermostat.current_hold_mode)
|
||||
assert 'heatClimate' == self.thermostat.current_hold_mode
|
||||
|
||||
def test_current_hold_mode_temperature_hold(self):
|
||||
"""Test current hold mode when temperature hold is set."""
|
||||
# Temperature hold
|
||||
self.ecobee['events'][0]['type'] = 'hold'
|
||||
self.ecobee['events'][0]['holdClimateRef'] = ''
|
||||
self.assertEqual('temp', self.thermostat.current_hold_mode)
|
||||
assert 'temp' == self.thermostat.current_hold_mode
|
||||
|
||||
def test_current_hold_mode_auto_hold(self):
|
||||
"""Test current hold mode when auto heat is set."""
|
||||
# auto Hold
|
||||
self.ecobee['events'][0]['type'] = 'autoHeat'
|
||||
self.assertEqual('heat', self.thermostat.current_hold_mode)
|
||||
assert 'heat' == self.thermostat.current_hold_mode
|
||||
|
||||
def test_current_operation(self):
|
||||
"""Test current operation property."""
|
||||
self.assertEqual('auto', self.thermostat.current_operation)
|
||||
assert 'auto' == self.thermostat.current_operation
|
||||
self.ecobee['settings']['hvacMode'] = 'heat'
|
||||
self.assertEqual('heat', self.thermostat.current_operation)
|
||||
assert 'heat' == self.thermostat.current_operation
|
||||
self.ecobee['settings']['hvacMode'] = 'cool'
|
||||
self.assertEqual('cool', self.thermostat.current_operation)
|
||||
assert 'cool' == self.thermostat.current_operation
|
||||
self.ecobee['settings']['hvacMode'] = 'auxHeatOnly'
|
||||
self.assertEqual('heat', self.thermostat.current_operation)
|
||||
assert 'heat' == self.thermostat.current_operation
|
||||
self.ecobee['settings']['hvacMode'] = 'off'
|
||||
self.assertEqual('off', self.thermostat.current_operation)
|
||||
assert 'off' == self.thermostat.current_operation
|
||||
|
||||
def test_operation_list(self):
|
||||
"""Test operation list property."""
|
||||
self.assertEqual(['auto', 'auxHeatOnly', 'cool',
|
||||
'heat', 'off'], self.thermostat.operation_list)
|
||||
assert ['auto', 'auxHeatOnly', 'cool',
|
||||
'heat', 'off'] == self.thermostat.operation_list
|
||||
|
||||
def test_operation_mode(self):
|
||||
"""Test operation mode property."""
|
||||
self.assertEqual('auto', self.thermostat.operation_mode)
|
||||
assert 'auto' == self.thermostat.operation_mode
|
||||
self.ecobee['settings']['hvacMode'] = 'heat'
|
||||
self.assertEqual('heat', self.thermostat.operation_mode)
|
||||
assert 'heat' == self.thermostat.operation_mode
|
||||
|
||||
def test_mode(self):
|
||||
"""Test mode property."""
|
||||
self.assertEqual('Climate1', self.thermostat.mode)
|
||||
assert 'Climate1' == self.thermostat.mode
|
||||
self.ecobee['program']['currentClimateRef'] = 'c2'
|
||||
self.assertEqual('Climate2', self.thermostat.mode)
|
||||
assert 'Climate2' == self.thermostat.mode
|
||||
|
||||
def test_fan_min_on_time(self):
|
||||
"""Test fan min on time property."""
|
||||
self.assertEqual(10, self.thermostat.fan_min_on_time)
|
||||
assert 10 == self.thermostat.fan_min_on_time
|
||||
self.ecobee['settings']['fanMinOnTime'] = 100
|
||||
self.assertEqual(100, self.thermostat.fan_min_on_time)
|
||||
assert 100 == self.thermostat.fan_min_on_time
|
||||
|
||||
def test_device_state_attributes(self):
|
||||
"""Test device state attributes property."""
|
||||
self.ecobee['equipmentStatus'] = 'heatPump2'
|
||||
self.assertEqual({'actual_humidity': 15,
|
||||
'climate_list': ['Climate1', 'Climate2'],
|
||||
'fan': 'off',
|
||||
'fan_min_on_time': 10,
|
||||
'climate_mode': 'Climate1',
|
||||
'operation': 'heat'},
|
||||
self.thermostat.device_state_attributes)
|
||||
assert {'actual_humidity': 15,
|
||||
'climate_list': ['Climate1', 'Climate2'],
|
||||
'fan': 'off',
|
||||
'fan_min_on_time': 10,
|
||||
'climate_mode': 'Climate1',
|
||||
'operation': 'heat'} == \
|
||||
self.thermostat.device_state_attributes
|
||||
|
||||
self.ecobee['equipmentStatus'] = 'auxHeat2'
|
||||
self.assertEqual({'actual_humidity': 15,
|
||||
'climate_list': ['Climate1', 'Climate2'],
|
||||
'fan': 'off',
|
||||
'fan_min_on_time': 10,
|
||||
'climate_mode': 'Climate1',
|
||||
'operation': 'heat'},
|
||||
self.thermostat.device_state_attributes)
|
||||
assert {'actual_humidity': 15,
|
||||
'climate_list': ['Climate1', 'Climate2'],
|
||||
'fan': 'off',
|
||||
'fan_min_on_time': 10,
|
||||
'climate_mode': 'Climate1',
|
||||
'operation': 'heat'} == \
|
||||
self.thermostat.device_state_attributes
|
||||
self.ecobee['equipmentStatus'] = 'compCool1'
|
||||
self.assertEqual({'actual_humidity': 15,
|
||||
'climate_list': ['Climate1', 'Climate2'],
|
||||
'fan': 'off',
|
||||
'fan_min_on_time': 10,
|
||||
'climate_mode': 'Climate1',
|
||||
'operation': 'cool'},
|
||||
self.thermostat.device_state_attributes)
|
||||
assert {'actual_humidity': 15,
|
||||
'climate_list': ['Climate1', 'Climate2'],
|
||||
'fan': 'off',
|
||||
'fan_min_on_time': 10,
|
||||
'climate_mode': 'Climate1',
|
||||
'operation': 'cool'} == \
|
||||
self.thermostat.device_state_attributes
|
||||
self.ecobee['equipmentStatus'] = ''
|
||||
self.assertEqual({'actual_humidity': 15,
|
||||
'climate_list': ['Climate1', 'Climate2'],
|
||||
'fan': 'off',
|
||||
'fan_min_on_time': 10,
|
||||
'climate_mode': 'Climate1',
|
||||
'operation': 'idle'},
|
||||
self.thermostat.device_state_attributes)
|
||||
assert {'actual_humidity': 15,
|
||||
'climate_list': ['Climate1', 'Climate2'],
|
||||
'fan': 'off',
|
||||
'fan_min_on_time': 10,
|
||||
'climate_mode': 'Climate1',
|
||||
'operation': 'idle'} == \
|
||||
self.thermostat.device_state_attributes
|
||||
|
||||
self.ecobee['equipmentStatus'] = 'Unknown'
|
||||
self.assertEqual({'actual_humidity': 15,
|
||||
'climate_list': ['Climate1', 'Climate2'],
|
||||
'fan': 'off',
|
||||
'fan_min_on_time': 10,
|
||||
'climate_mode': 'Climate1',
|
||||
'operation': 'Unknown'},
|
||||
self.thermostat.device_state_attributes)
|
||||
assert {'actual_humidity': 15,
|
||||
'climate_list': ['Climate1', 'Climate2'],
|
||||
'fan': 'off',
|
||||
'fan_min_on_time': 10,
|
||||
'climate_mode': 'Climate1',
|
||||
'operation': 'Unknown'} == \
|
||||
self.thermostat.device_state_attributes
|
||||
|
||||
def test_is_away_mode_on(self):
|
||||
"""Test away mode property."""
|
||||
self.assertFalse(self.thermostat.is_away_mode_on)
|
||||
assert not self.thermostat.is_away_mode_on
|
||||
# Temporary away hold
|
||||
self.ecobee['events'][0]['endDate'] = '2018-01-01 11:12:12'
|
||||
self.assertFalse(self.thermostat.is_away_mode_on)
|
||||
assert not self.thermostat.is_away_mode_on
|
||||
# Permanent away hold
|
||||
self.ecobee['events'][0]['endDate'] = '2019-01-01 13:12:12'
|
||||
self.assertTrue(self.thermostat.is_away_mode_on)
|
||||
assert self.thermostat.is_away_mode_on
|
||||
# No running events
|
||||
self.ecobee['events'][0]['running'] = False
|
||||
self.assertFalse(self.thermostat.is_away_mode_on)
|
||||
assert not self.thermostat.is_away_mode_on
|
||||
# Vacation Hold
|
||||
self.ecobee['events'][0]['type'] = 'vacation'
|
||||
self.assertFalse(self.thermostat.is_away_mode_on)
|
||||
assert not self.thermostat.is_away_mode_on
|
||||
# Preset climate hold
|
||||
self.ecobee['events'][0]['type'] = 'hold'
|
||||
self.ecobee['events'][0]['holdClimateRef'] = 'heatClimate'
|
||||
self.assertFalse(self.thermostat.is_away_mode_on)
|
||||
assert not self.thermostat.is_away_mode_on
|
||||
# Temperature hold
|
||||
self.ecobee['events'][0]['type'] = 'hold'
|
||||
self.ecobee['events'][0]['holdClimateRef'] = ''
|
||||
self.assertFalse(self.thermostat.is_away_mode_on)
|
||||
assert not self.thermostat.is_away_mode_on
|
||||
# auto Hold
|
||||
self.ecobee['events'][0]['type'] = 'autoHeat'
|
||||
self.assertFalse(self.thermostat.is_away_mode_on)
|
||||
assert not self.thermostat.is_away_mode_on
|
||||
|
||||
def test_is_aux_heat_on(self):
|
||||
"""Test aux heat property."""
|
||||
self.assertFalse(self.thermostat.is_aux_heat_on)
|
||||
assert not self.thermostat.is_aux_heat_on
|
||||
self.ecobee['equipmentStatus'] = 'fan, auxHeat'
|
||||
self.assertTrue(self.thermostat.is_aux_heat_on)
|
||||
assert self.thermostat.is_aux_heat_on
|
||||
|
||||
def test_turn_away_mode_on_off(self):
|
||||
"""Test turn away mode setter."""
|
||||
@@ -265,7 +265,7 @@ class TestEcobee(unittest.TestCase):
|
||||
self.data.reset_mock()
|
||||
self.ecobee['events'][0]['endDate'] = '2019-01-01 11:12:12'
|
||||
# Should not call set_climate_hold()
|
||||
self.assertFalse(self.data.ecobee.set_climate_hold.called)
|
||||
assert not self.data.ecobee.set_climate_hold.called
|
||||
|
||||
# Try turning off while hold mode is away hold
|
||||
self.data.reset_mock()
|
||||
@@ -276,7 +276,7 @@ class TestEcobee(unittest.TestCase):
|
||||
self.data.reset_mock()
|
||||
self.ecobee['events'][0]['endDate'] = '2017-01-01 14:00:00'
|
||||
self.thermostat.turn_away_mode_off()
|
||||
self.assertFalse(self.data.ecobee.resume_program.called)
|
||||
assert not self.data.ecobee.resume_program.called
|
||||
|
||||
def test_set_hold_mode(self):
|
||||
"""Test hold mode setter."""
|
||||
@@ -284,18 +284,18 @@ class TestEcobee(unittest.TestCase):
|
||||
# Away->Away
|
||||
self.data.reset_mock()
|
||||
self.thermostat.set_hold_mode('away')
|
||||
self.assertFalse(self.data.ecobee.delete_vacation.called)
|
||||
self.assertFalse(self.data.ecobee.resume_program.called)
|
||||
self.assertFalse(self.data.ecobee.set_hold_temp.called)
|
||||
self.assertFalse(self.data.ecobee.set_climate_hold.called)
|
||||
assert not self.data.ecobee.delete_vacation.called
|
||||
assert not self.data.ecobee.resume_program.called
|
||||
assert not self.data.ecobee.set_hold_temp.called
|
||||
assert not self.data.ecobee.set_climate_hold.called
|
||||
|
||||
# Away->'None'
|
||||
self.data.reset_mock()
|
||||
self.thermostat.set_hold_mode('None')
|
||||
self.assertFalse(self.data.ecobee.delete_vacation.called)
|
||||
assert not self.data.ecobee.delete_vacation.called
|
||||
self.data.ecobee.resume_program.assert_has_calls([mock.call(1)])
|
||||
self.assertFalse(self.data.ecobee.set_hold_temp.called)
|
||||
self.assertFalse(self.data.ecobee.set_climate_hold.called)
|
||||
assert not self.data.ecobee.set_hold_temp.called
|
||||
assert not self.data.ecobee.set_climate_hold.called
|
||||
|
||||
# Vacation Hold -> None
|
||||
self.ecobee['events'][0]['type'] = 'vacation'
|
||||
@@ -303,28 +303,28 @@ class TestEcobee(unittest.TestCase):
|
||||
self.thermostat.set_hold_mode(None)
|
||||
self.data.ecobee.delete_vacation.assert_has_calls(
|
||||
[mock.call(1, 'Event1')])
|
||||
self.assertFalse(self.data.ecobee.resume_program.called)
|
||||
self.assertFalse(self.data.ecobee.set_hold_temp.called)
|
||||
self.assertFalse(self.data.ecobee.set_climate_hold.called)
|
||||
assert not self.data.ecobee.resume_program.called
|
||||
assert not self.data.ecobee.set_hold_temp.called
|
||||
assert not self.data.ecobee.set_climate_hold.called
|
||||
|
||||
# Away -> home, sleep
|
||||
for hold in ['home', 'sleep']:
|
||||
self.data.reset_mock()
|
||||
self.thermostat.set_hold_mode(hold)
|
||||
self.assertFalse(self.data.ecobee.delete_vacation.called)
|
||||
self.assertFalse(self.data.ecobee.resume_program.called)
|
||||
self.assertFalse(self.data.ecobee.set_hold_temp.called)
|
||||
assert not self.data.ecobee.delete_vacation.called
|
||||
assert not self.data.ecobee.resume_program.called
|
||||
assert not self.data.ecobee.set_hold_temp.called
|
||||
self.data.ecobee.set_climate_hold.assert_has_calls(
|
||||
[mock.call(1, hold, 'nextTransition')])
|
||||
|
||||
# Away -> temp
|
||||
self.data.reset_mock()
|
||||
self.thermostat.set_hold_mode('temp')
|
||||
self.assertFalse(self.data.ecobee.delete_vacation.called)
|
||||
self.assertFalse(self.data.ecobee.resume_program.called)
|
||||
assert not self.data.ecobee.delete_vacation.called
|
||||
assert not self.data.ecobee.resume_program.called
|
||||
self.data.ecobee.set_hold_temp.assert_has_calls(
|
||||
[mock.call(1, 35.0, 25.0, 'nextTransition')])
|
||||
self.assertFalse(self.data.ecobee.set_climate_hold.called)
|
||||
assert not self.data.ecobee.set_climate_hold.called
|
||||
|
||||
def test_set_auto_temp_hold(self):
|
||||
"""Test auto temp hold setter."""
|
||||
@@ -389,7 +389,7 @@ class TestEcobee(unittest.TestCase):
|
||||
self.ecobee['settings']['hvacMode'] = 'heat'
|
||||
self.thermostat.set_temperature(target_temp_low=20,
|
||||
target_temp_high=30)
|
||||
self.assertFalse(self.data.ecobee.set_hold_temp.called)
|
||||
assert not self.data.ecobee.set_hold_temp.called
|
||||
|
||||
def test_set_operation_mode(self):
|
||||
"""Test operation mode setter."""
|
||||
@@ -441,17 +441,17 @@ class TestEcobee(unittest.TestCase):
|
||||
|
||||
def test_hold_preference(self):
|
||||
"""Test hold preference."""
|
||||
self.assertEqual('nextTransition', self.thermostat.hold_preference())
|
||||
assert 'nextTransition' == self.thermostat.hold_preference()
|
||||
for action in ['useEndTime4hour', 'useEndTime2hour',
|
||||
'nextPeriod', 'indefinite', 'askMe']:
|
||||
self.ecobee['settings']['holdAction'] = action
|
||||
self.assertEqual('nextTransition',
|
||||
self.thermostat.hold_preference())
|
||||
assert 'nextTransition' == \
|
||||
self.thermostat.hold_preference()
|
||||
|
||||
def test_climate_list(self):
|
||||
"""Test climate list property."""
|
||||
self.assertEqual(['Climate1', 'Climate2'],
|
||||
self.thermostat.climate_list)
|
||||
assert ['Climate1', 'Climate2'] == \
|
||||
self.thermostat.climate_list
|
||||
|
||||
def test_set_fan_mode_on(self):
|
||||
"""Test set fan mode to on."""
|
||||
|
||||
@@ -30,46 +30,46 @@ class TestFritzboxClimate(unittest.TestCase):
|
||||
|
||||
def test_init(self):
|
||||
"""Test instance creation."""
|
||||
self.assertEqual(18.0, self.thermostat._current_temperature)
|
||||
self.assertEqual(19.5, self.thermostat._target_temperature)
|
||||
self.assertEqual(22.0, self.thermostat._comfort_temperature)
|
||||
self.assertEqual(16.0, self.thermostat._eco_temperature)
|
||||
assert 18.0 == self.thermostat._current_temperature
|
||||
assert 19.5 == self.thermostat._target_temperature
|
||||
assert 22.0 == self.thermostat._comfort_temperature
|
||||
assert 16.0 == self.thermostat._eco_temperature
|
||||
|
||||
def test_supported_features(self):
|
||||
"""Test supported features property."""
|
||||
self.assertEqual(129, self.thermostat.supported_features)
|
||||
assert 129 == self.thermostat.supported_features
|
||||
|
||||
def test_available(self):
|
||||
"""Test available property."""
|
||||
self.assertTrue(self.thermostat.available)
|
||||
assert self.thermostat.available
|
||||
self.thermostat._device.present = False
|
||||
self.assertFalse(self.thermostat.available)
|
||||
assert not self.thermostat.available
|
||||
|
||||
def test_name(self):
|
||||
"""Test name property."""
|
||||
self.assertEqual('Test Thermostat', self.thermostat.name)
|
||||
assert 'Test Thermostat' == self.thermostat.name
|
||||
|
||||
def test_temperature_unit(self):
|
||||
"""Test temperature_unit property."""
|
||||
self.assertEqual('°C', self.thermostat.temperature_unit)
|
||||
assert '°C' == self.thermostat.temperature_unit
|
||||
|
||||
def test_precision(self):
|
||||
"""Test precision property."""
|
||||
self.assertEqual(0.5, self.thermostat.precision)
|
||||
assert 0.5 == self.thermostat.precision
|
||||
|
||||
def test_current_temperature(self):
|
||||
"""Test current_temperature property incl. special temperatures."""
|
||||
self.assertEqual(18, self.thermostat.current_temperature)
|
||||
assert 18 == self.thermostat.current_temperature
|
||||
|
||||
def test_target_temperature(self):
|
||||
"""Test target_temperature property."""
|
||||
self.assertEqual(19.5, self.thermostat.target_temperature)
|
||||
assert 19.5 == self.thermostat.target_temperature
|
||||
|
||||
self.thermostat._target_temperature = 126.5
|
||||
self.assertEqual(None, self.thermostat.target_temperature)
|
||||
assert self.thermostat.target_temperature is None
|
||||
|
||||
self.thermostat._target_temperature = 127.0
|
||||
self.assertEqual(None, self.thermostat.target_temperature)
|
||||
assert self.thermostat.target_temperature is None
|
||||
|
||||
@patch.object(FritzboxThermostat, 'set_operation_mode')
|
||||
def test_set_temperature_operation_mode(self, mock_set_op):
|
||||
@@ -101,20 +101,20 @@ class TestFritzboxClimate(unittest.TestCase):
|
||||
def test_current_operation(self):
|
||||
"""Test operation mode property for different temperatures."""
|
||||
self.thermostat._target_temperature = 127.0
|
||||
self.assertEqual('on', self.thermostat.current_operation)
|
||||
assert 'on' == self.thermostat.current_operation
|
||||
self.thermostat._target_temperature = 126.5
|
||||
self.assertEqual('off', self.thermostat.current_operation)
|
||||
assert 'off' == self.thermostat.current_operation
|
||||
self.thermostat._target_temperature = 22.0
|
||||
self.assertEqual('heat', self.thermostat.current_operation)
|
||||
assert 'heat' == self.thermostat.current_operation
|
||||
self.thermostat._target_temperature = 16.0
|
||||
self.assertEqual('eco', self.thermostat.current_operation)
|
||||
assert 'eco' == self.thermostat.current_operation
|
||||
self.thermostat._target_temperature = 12.5
|
||||
self.assertEqual('manual', self.thermostat.current_operation)
|
||||
assert 'manual' == self.thermostat.current_operation
|
||||
|
||||
def test_operation_list(self):
|
||||
"""Test operation_list property."""
|
||||
self.assertEqual(['heat', 'eco', 'off', 'on'],
|
||||
self.thermostat.operation_list)
|
||||
assert ['heat', 'eco', 'off', 'on'] == \
|
||||
self.thermostat.operation_list
|
||||
|
||||
@patch.object(FritzboxThermostat, 'set_temperature')
|
||||
def test_set_operation_mode(self, mock_set_temp):
|
||||
@@ -137,15 +137,15 @@ class TestFritzboxClimate(unittest.TestCase):
|
||||
|
||||
def test_min_max_temperature(self):
|
||||
"""Test min_temp and max_temp properties."""
|
||||
self.assertEqual(8.0, self.thermostat.min_temp)
|
||||
self.assertEqual(28.0, self.thermostat.max_temp)
|
||||
assert 8.0 == self.thermostat.min_temp
|
||||
assert 28.0 == self.thermostat.max_temp
|
||||
|
||||
def test_device_state_attributes(self):
|
||||
"""Test device_state property."""
|
||||
attr = self.thermostat.device_state_attributes
|
||||
self.assertEqual(attr['device_locked'], True)
|
||||
self.assertEqual(attr['locked'], False)
|
||||
self.assertEqual(attr['battery_low'], True)
|
||||
assert attr['device_locked'] is True
|
||||
assert attr['locked'] is False
|
||||
assert attr['battery_low'] is True
|
||||
|
||||
def test_update(self):
|
||||
"""Test update function."""
|
||||
@@ -160,10 +160,10 @@ class TestFritzboxClimate(unittest.TestCase):
|
||||
self.thermostat.update()
|
||||
|
||||
device.update.assert_called_once_with()
|
||||
self.assertEqual(10.0, self.thermostat._current_temperature)
|
||||
self.assertEqual(11.0, self.thermostat._target_temperature)
|
||||
self.assertEqual(12.0, self.thermostat._comfort_temperature)
|
||||
self.assertEqual(13.0, self.thermostat._eco_temperature)
|
||||
assert 10.0 == self.thermostat._current_temperature
|
||||
assert 11.0 == self.thermostat._target_temperature
|
||||
assert 12.0 == self.thermostat._comfort_temperature
|
||||
assert 13.0 == self.thermostat._eco_temperature
|
||||
|
||||
def test_update_http_error(self):
|
||||
"""Test exception handling of update function."""
|
||||
|
||||
@@ -62,15 +62,13 @@ class TestSetupClimateGenericThermostat(unittest.TestCase):
|
||||
|
||||
def test_valid_conf(self):
|
||||
"""Test set up generic_thermostat with valid config values."""
|
||||
self.assertTrue(
|
||||
setup_component(self.hass, 'climate',
|
||||
{'climate': {
|
||||
'platform': 'generic_thermostat',
|
||||
'name': 'test',
|
||||
'heater': ENT_SWITCH,
|
||||
'target_sensor': ENT_SENSOR
|
||||
}})
|
||||
)
|
||||
assert setup_component(self.hass, 'climate', {
|
||||
'climate': {
|
||||
'platform': 'generic_thermostat',
|
||||
'name': 'test',
|
||||
'heater': ENT_SWITCH,
|
||||
'target_sensor': ENT_SENSOR
|
||||
}})
|
||||
|
||||
|
||||
class TestGenericThermostatHeaterSwitching(unittest.TestCase):
|
||||
@@ -83,9 +81,9 @@ class TestGenericThermostatHeaterSwitching(unittest.TestCase):
|
||||
"""Set up things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
self.hass.config.units = METRIC_SYSTEM
|
||||
self.assertTrue(run_coroutine_threadsafe(
|
||||
assert run_coroutine_threadsafe(
|
||||
comps.async_setup(self.hass, {}), self.hass.loop
|
||||
).result())
|
||||
).result()
|
||||
|
||||
def tearDown(self): # pylint: disable=invalid-name
|
||||
"""Stop down everything that was started."""
|
||||
@@ -104,16 +102,16 @@ class TestGenericThermostatHeaterSwitching(unittest.TestCase):
|
||||
'target_sensor': ENT_SENSOR
|
||||
}})
|
||||
|
||||
self.assertEqual(STATE_OFF,
|
||||
self.hass.states.get(heater_switch).state)
|
||||
assert STATE_OFF == \
|
||||
self.hass.states.get(heater_switch).state
|
||||
|
||||
self._setup_sensor(18)
|
||||
self.hass.block_till_done()
|
||||
common.set_temperature(self.hass, 23)
|
||||
self.hass.block_till_done()
|
||||
|
||||
self.assertEqual(STATE_ON,
|
||||
self.hass.states.get(heater_switch).state)
|
||||
assert STATE_ON == \
|
||||
self.hass.states.get(heater_switch).state
|
||||
|
||||
def test_heater_switch(self):
|
||||
"""Test heater switching test switch."""
|
||||
@@ -131,16 +129,16 @@ class TestGenericThermostatHeaterSwitching(unittest.TestCase):
|
||||
'target_sensor': ENT_SENSOR
|
||||
}})
|
||||
|
||||
self.assertEqual(STATE_OFF,
|
||||
self.hass.states.get(heater_switch).state)
|
||||
assert STATE_OFF == \
|
||||
self.hass.states.get(heater_switch).state
|
||||
|
||||
self._setup_sensor(18)
|
||||
self.hass.block_till_done()
|
||||
common.set_temperature(self.hass, 23)
|
||||
self.hass.block_till_done()
|
||||
|
||||
self.assertEqual(STATE_ON,
|
||||
self.hass.states.get(heater_switch).state)
|
||||
assert STATE_ON == \
|
||||
self.hass.states.get(heater_switch).state
|
||||
|
||||
def _setup_sensor(self, temp):
|
||||
"""Set up the test sensor."""
|
||||
@@ -170,31 +168,31 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
|
||||
def test_setup_defaults_to_unknown(self):
|
||||
"""Test the setting of defaults to unknown."""
|
||||
self.assertEqual(STATE_IDLE, self.hass.states.get(ENTITY).state)
|
||||
assert STATE_IDLE == self.hass.states.get(ENTITY).state
|
||||
|
||||
def test_default_setup_params(self):
|
||||
"""Test the setup with default parameters."""
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(7, state.attributes.get('min_temp'))
|
||||
self.assertEqual(35, state.attributes.get('max_temp'))
|
||||
self.assertEqual(7, state.attributes.get('temperature'))
|
||||
assert 7 == state.attributes.get('min_temp')
|
||||
assert 35 == state.attributes.get('max_temp')
|
||||
assert 7 == state.attributes.get('temperature')
|
||||
|
||||
def test_get_operation_modes(self):
|
||||
"""Test that the operation list returns the correct modes."""
|
||||
state = self.hass.states.get(ENTITY)
|
||||
modes = state.attributes.get('operation_list')
|
||||
self.assertEqual([climate.STATE_HEAT, STATE_OFF], modes)
|
||||
assert [climate.STATE_HEAT, STATE_OFF] == modes
|
||||
|
||||
def test_set_target_temp(self):
|
||||
"""Test the setting of the target temperature."""
|
||||
common.set_temperature(self.hass, 30)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(30.0, state.attributes.get('temperature'))
|
||||
assert 30.0 == state.attributes.get('temperature')
|
||||
common.set_temperature(self.hass, None)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(30.0, state.attributes.get('temperature'))
|
||||
assert 30.0 == state.attributes.get('temperature')
|
||||
|
||||
def test_set_away_mode(self):
|
||||
"""Test the setting away mode."""
|
||||
@@ -203,7 +201,7 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
common.set_away_mode(self.hass, True)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(16, state.attributes.get('temperature'))
|
||||
assert 16 == state.attributes.get('temperature')
|
||||
|
||||
def test_set_away_mode_and_restore_prev_temp(self):
|
||||
"""Test the setting and removing away mode.
|
||||
@@ -215,11 +213,11 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
common.set_away_mode(self.hass, True)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(16, state.attributes.get('temperature'))
|
||||
assert 16 == state.attributes.get('temperature')
|
||||
common.set_away_mode(self.hass, False)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(23, state.attributes.get('temperature'))
|
||||
assert 23 == state.attributes.get('temperature')
|
||||
|
||||
def test_set_away_mode_twice_and_restore_prev_temp(self):
|
||||
"""Test the setting away mode twice in a row.
|
||||
@@ -233,11 +231,11 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
common.set_away_mode(self.hass, True)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(16, state.attributes.get('temperature'))
|
||||
assert 16 == state.attributes.get('temperature')
|
||||
common.set_away_mode(self.hass, False)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(23, state.attributes.get('temperature'))
|
||||
assert 23 == state.attributes.get('temperature')
|
||||
|
||||
def test_sensor_bad_value(self):
|
||||
"""Test sensor that have None as state."""
|
||||
@@ -248,7 +246,7 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(temp, state.attributes.get('current_temperature'))
|
||||
assert temp == state.attributes.get('current_temperature')
|
||||
|
||||
def test_set_target_temp_heater_on(self):
|
||||
"""Test if target temperature turn heater on."""
|
||||
@@ -257,11 +255,11 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
common.set_temperature(self.hass, 30)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_ON, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_ON == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_set_target_temp_heater_off(self):
|
||||
"""Test if target temperature turn heater off."""
|
||||
@@ -270,11 +268,11 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
common.set_temperature(self.hass, 25)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(2, len(self.calls))
|
||||
assert 2 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_OFF == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_temp_change_heater_on_within_tolerance(self):
|
||||
"""Test if temperature change doesn't turn on within tolerance."""
|
||||
@@ -283,7 +281,7 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(29)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
|
||||
def test_temp_change_heater_on_outside_tolerance(self):
|
||||
"""Test if temperature change turn heater on outside cold tolerance."""
|
||||
@@ -292,11 +290,11 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(27)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_ON, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_ON == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_temp_change_heater_off_within_tolerance(self):
|
||||
"""Test if temperature change doesn't turn off within tolerance."""
|
||||
@@ -305,7 +303,7 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(33)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
|
||||
def test_temp_change_heater_off_outside_tolerance(self):
|
||||
"""Test if temperature change turn heater off outside hot tolerance."""
|
||||
@@ -314,11 +312,11 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(35)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_OFF == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_running_when_operating_mode_is_off(self):
|
||||
"""Test that the switch turns off when enabled is set False."""
|
||||
@@ -327,11 +325,11 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
common.set_operation_mode(self.hass, STATE_OFF)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_OFF == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_no_state_change_when_operation_mode_off(self):
|
||||
"""Test that the switch doesn't turn on when enabled is False."""
|
||||
@@ -342,14 +340,14 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(25)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
|
||||
@mock.patch('logging.Logger.error')
|
||||
def test_invalid_operating_mode(self, log_mock):
|
||||
"""Test error handling for invalid operation mode."""
|
||||
common.set_operation_mode(self.hass, 'invalid mode')
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(log_mock.call_count, 1)
|
||||
assert log_mock.call_count == 1
|
||||
|
||||
def test_operating_mode_heat(self):
|
||||
"""Test change mode from OFF to HEAT.
|
||||
@@ -363,11 +361,11 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
self._setup_switch(False)
|
||||
common.set_operation_mode(self.hass, climate.STATE_HEAT)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_ON, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_ON == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def _setup_sensor(self, temp):
|
||||
"""Set up the test sensor."""
|
||||
@@ -416,11 +414,11 @@ class TestClimateGenericThermostatACMode(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
common.set_temperature(self.hass, 30)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(2, len(self.calls))
|
||||
assert 2 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_OFF == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_turn_away_mode_on_cooling(self):
|
||||
"""Test the setting away mode when cooling."""
|
||||
@@ -431,7 +429,7 @@ class TestClimateGenericThermostatACMode(unittest.TestCase):
|
||||
common.set_away_mode(self.hass, True)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(30, state.attributes.get('temperature'))
|
||||
assert 30 == state.attributes.get('temperature')
|
||||
|
||||
def test_operating_mode_cool(self):
|
||||
"""Test change mode from OFF to COOL.
|
||||
@@ -445,11 +443,11 @@ class TestClimateGenericThermostatACMode(unittest.TestCase):
|
||||
self._setup_switch(False)
|
||||
common.set_operation_mode(self.hass, climate.STATE_COOL)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_ON, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_ON == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_set_target_temp_ac_on(self):
|
||||
"""Test if target temperature turn ac on."""
|
||||
@@ -458,11 +456,11 @@ class TestClimateGenericThermostatACMode(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
common.set_temperature(self.hass, 25)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_ON, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_ON == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_temp_change_ac_off_within_tolerance(self):
|
||||
"""Test if temperature change doesn't turn ac off within tolerance."""
|
||||
@@ -471,7 +469,7 @@ class TestClimateGenericThermostatACMode(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(29.8)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
|
||||
def test_set_temp_change_ac_off_outside_tolerance(self):
|
||||
"""Test if temperature change turn ac off."""
|
||||
@@ -480,11 +478,11 @@ class TestClimateGenericThermostatACMode(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(27)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_OFF == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_temp_change_ac_on_within_tolerance(self):
|
||||
"""Test if temperature change doesn't turn ac on within tolerance."""
|
||||
@@ -493,7 +491,7 @@ class TestClimateGenericThermostatACMode(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(25.2)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
|
||||
def test_temp_change_ac_on_outside_tolerance(self):
|
||||
"""Test if temperature change turn ac on."""
|
||||
@@ -502,11 +500,11 @@ class TestClimateGenericThermostatACMode(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(30)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_ON, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_ON == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_running_when_operating_mode_is_off(self):
|
||||
"""Test that the switch turns off when enabled is set False."""
|
||||
@@ -515,11 +513,11 @@ class TestClimateGenericThermostatACMode(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
common.set_operation_mode(self.hass, STATE_OFF)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_OFF == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_no_state_change_when_operation_mode_off(self):
|
||||
"""Test that the switch doesn't turn on when enabled is False."""
|
||||
@@ -530,7 +528,7 @@ class TestClimateGenericThermostatACMode(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(35)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
|
||||
def _setup_sensor(self, temp):
|
||||
"""Set up the test sensor."""
|
||||
@@ -579,7 +577,7 @@ class TestClimateGenericThermostatACModeMinCycle(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(30)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
|
||||
def test_temp_change_ac_trigger_on_long_enough(self):
|
||||
"""Test if temperature change turn ac on."""
|
||||
@@ -592,11 +590,11 @@ class TestClimateGenericThermostatACModeMinCycle(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(30)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_ON, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_ON == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_temp_change_ac_trigger_off_not_long_enough(self):
|
||||
"""Test if temperature change turn ac on."""
|
||||
@@ -605,7 +603,7 @@ class TestClimateGenericThermostatACModeMinCycle(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(25)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
|
||||
def test_temp_change_ac_trigger_off_long_enough(self):
|
||||
"""Test if temperature change turn ac on."""
|
||||
@@ -618,11 +616,11 @@ class TestClimateGenericThermostatACModeMinCycle(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(25)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_OFF == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def _setup_sensor(self, temp):
|
||||
"""Set up the test sensor."""
|
||||
@@ -670,7 +668,7 @@ class TestClimateGenericThermostatMinCycle(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(30)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
|
||||
def test_temp_change_heater_trigger_on_not_long_enough(self):
|
||||
"""Test if temp change doesn't turn heater on because of time."""
|
||||
@@ -679,7 +677,7 @@ class TestClimateGenericThermostatMinCycle(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(25)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
|
||||
def test_temp_change_heater_trigger_on_long_enough(self):
|
||||
"""Test if temperature change turn heater on after min cycle."""
|
||||
@@ -692,11 +690,11 @@ class TestClimateGenericThermostatMinCycle(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(25)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_ON, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_ON == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_temp_change_heater_trigger_off_long_enough(self):
|
||||
"""Test if temperature change turn heater off after min cycle."""
|
||||
@@ -709,11 +707,11 @@ class TestClimateGenericThermostatMinCycle(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self._setup_sensor(30)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_OFF == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def _setup_sensor(self, temp):
|
||||
"""Set up the test sensor."""
|
||||
@@ -767,17 +765,17 @@ class TestClimateGenericThermostatACKeepAlive(unittest.TestCase):
|
||||
test_time = datetime.datetime.now(pytz.UTC)
|
||||
self._send_time_changed(test_time)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
self._send_time_changed(test_time + datetime.timedelta(minutes=5))
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
self._send_time_changed(test_time + datetime.timedelta(minutes=10))
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_ON, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_ON == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_temp_change_ac_trigger_off_long_enough(self):
|
||||
"""Test if turn on signal is sent at keep-alive intervals."""
|
||||
@@ -790,17 +788,17 @@ class TestClimateGenericThermostatACKeepAlive(unittest.TestCase):
|
||||
test_time = datetime.datetime.now(pytz.UTC)
|
||||
self._send_time_changed(test_time)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
self._send_time_changed(test_time + datetime.timedelta(minutes=5))
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
self._send_time_changed(test_time + datetime.timedelta(minutes=10))
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_OFF == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def _send_time_changed(self, now):
|
||||
"""Send a time changed event."""
|
||||
@@ -857,17 +855,17 @@ class TestClimateGenericThermostatKeepAlive(unittest.TestCase):
|
||||
test_time = datetime.datetime.now(pytz.UTC)
|
||||
self._send_time_changed(test_time)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
self._send_time_changed(test_time + datetime.timedelta(minutes=5))
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
self._send_time_changed(test_time + datetime.timedelta(minutes=10))
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_ON, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_ON == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def test_temp_change_heater_trigger_off_long_enough(self):
|
||||
"""Test if turn on signal is sent at keep-alive intervals."""
|
||||
@@ -880,17 +878,17 @@ class TestClimateGenericThermostatKeepAlive(unittest.TestCase):
|
||||
test_time = datetime.datetime.now(pytz.UTC)
|
||||
self._send_time_changed(test_time)
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
self._send_time_changed(test_time + datetime.timedelta(minutes=5))
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 0 == len(self.calls)
|
||||
self._send_time_changed(test_time + datetime.timedelta(minutes=10))
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert 1 == len(self.calls)
|
||||
call = self.calls[0]
|
||||
self.assertEqual('homeassistant', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
||||
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||
assert 'homeassistant' == call.domain
|
||||
assert SERVICE_TURN_OFF == call.service
|
||||
assert ENT_SWITCH == call.data['entity_id']
|
||||
|
||||
def _send_time_changed(self, now):
|
||||
"""Send a time changed event."""
|
||||
@@ -951,10 +949,10 @@ class TestClimateGenericThermostatTurnOnOff(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
state_heat = self.hass.states.get(self.HEAT_ENTITY)
|
||||
state_cool = self.hass.states.get(self.COOL_ENTITY)
|
||||
self.assertEqual(STATE_HEAT,
|
||||
state_heat.attributes.get('operation_mode'))
|
||||
self.assertEqual(STATE_COOL,
|
||||
state_cool.attributes.get('operation_mode'))
|
||||
assert STATE_HEAT == \
|
||||
state_heat.attributes.get('operation_mode')
|
||||
assert STATE_COOL == \
|
||||
state_cool.attributes.get('operation_mode')
|
||||
|
||||
def test_turn_on_when_on(self):
|
||||
"""Test if climate.turn_on does nothing to a turned on device."""
|
||||
@@ -965,10 +963,10 @@ class TestClimateGenericThermostatTurnOnOff(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
state_heat = self.hass.states.get(self.HEAT_ENTITY)
|
||||
state_cool = self.hass.states.get(self.COOL_ENTITY)
|
||||
self.assertEqual(STATE_HEAT,
|
||||
state_heat.attributes.get('operation_mode'))
|
||||
self.assertEqual(STATE_COOL,
|
||||
state_cool.attributes.get('operation_mode'))
|
||||
assert STATE_HEAT == \
|
||||
state_heat.attributes.get('operation_mode')
|
||||
assert STATE_COOL == \
|
||||
state_cool.attributes.get('operation_mode')
|
||||
|
||||
def test_turn_off_when_on(self):
|
||||
"""Test if climate.turn_off turns off a turned on device."""
|
||||
@@ -979,10 +977,10 @@ class TestClimateGenericThermostatTurnOnOff(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
state_heat = self.hass.states.get(self.HEAT_ENTITY)
|
||||
state_cool = self.hass.states.get(self.COOL_ENTITY)
|
||||
self.assertEqual(STATE_OFF,
|
||||
state_heat.attributes.get('operation_mode'))
|
||||
self.assertEqual(STATE_OFF,
|
||||
state_cool.attributes.get('operation_mode'))
|
||||
assert STATE_OFF == \
|
||||
state_heat.attributes.get('operation_mode')
|
||||
assert STATE_OFF == \
|
||||
state_cool.attributes.get('operation_mode')
|
||||
|
||||
def test_turn_off_when_off(self):
|
||||
"""Test if climate.turn_off does nothing to a turned off device."""
|
||||
@@ -992,10 +990,10 @@ class TestClimateGenericThermostatTurnOnOff(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
state_heat = self.hass.states.get(self.HEAT_ENTITY)
|
||||
state_cool = self.hass.states.get(self.COOL_ENTITY)
|
||||
self.assertEqual(STATE_OFF,
|
||||
state_heat.attributes.get('operation_mode'))
|
||||
self.assertEqual(STATE_OFF,
|
||||
state_cool.attributes.get('operation_mode'))
|
||||
assert STATE_OFF == \
|
||||
state_heat.attributes.get('operation_mode')
|
||||
assert STATE_OFF == \
|
||||
state_cool.attributes.get('operation_mode')
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
@@ -1096,18 +1094,18 @@ class TestClimateGenericThermostatRestoreState(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(20, state.attributes[ATTR_TEMPERATURE])
|
||||
self.assertEqual(STATE_OFF,
|
||||
state.attributes[climate.ATTR_OPERATION_MODE])
|
||||
self.assertEqual(STATE_OFF, state.state)
|
||||
self.assertEqual(0, len(self.calls))
|
||||
assert 20 == state.attributes[ATTR_TEMPERATURE]
|
||||
assert STATE_OFF == \
|
||||
state.attributes[climate.ATTR_OPERATION_MODE]
|
||||
assert STATE_OFF == state.state
|
||||
assert 0 == len(self.calls)
|
||||
|
||||
self._setup_switch(False)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(STATE_OFF,
|
||||
state.attributes[climate.ATTR_OPERATION_MODE])
|
||||
self.assertEqual(STATE_OFF, state.state)
|
||||
assert STATE_OFF == \
|
||||
state.attributes[climate.ATTR_OPERATION_MODE]
|
||||
assert STATE_OFF == state.state
|
||||
|
||||
def _setup_climate(self):
|
||||
assert setup_component(self.hass, climate.DOMAIN, {'climate': {
|
||||
|
||||
@@ -12,6 +12,7 @@ from homeassistant.components.climate import (
|
||||
ATTR_FAN_MODE, ATTR_OPERATION_MODE, ATTR_FAN_LIST, ATTR_OPERATION_LIST)
|
||||
|
||||
import homeassistant.components.climate.honeywell as honeywell
|
||||
import pytest
|
||||
|
||||
|
||||
class TestHoneywell(unittest.TestCase):
|
||||
@@ -43,16 +44,16 @@ class TestHoneywell(unittest.TestCase):
|
||||
honeywell.CONF_REGION: 'un',
|
||||
}
|
||||
|
||||
with self.assertRaises(vol.Invalid):
|
||||
with pytest.raises(vol.Invalid):
|
||||
honeywell.PLATFORM_SCHEMA(None)
|
||||
|
||||
with self.assertRaises(vol.Invalid):
|
||||
with pytest.raises(vol.Invalid):
|
||||
honeywell.PLATFORM_SCHEMA({})
|
||||
|
||||
with self.assertRaises(vol.Invalid):
|
||||
with pytest.raises(vol.Invalid):
|
||||
honeywell.PLATFORM_SCHEMA(bad_pass_config)
|
||||
|
||||
with self.assertRaises(vol.Invalid):
|
||||
with pytest.raises(vol.Invalid):
|
||||
honeywell.PLATFORM_SCHEMA(bad_region_config)
|
||||
|
||||
hass = mock.MagicMock()
|
||||
@@ -70,9 +71,9 @@ class TestHoneywell(unittest.TestCase):
|
||||
locations[1].devices_by_id.values.return_value = devices_2
|
||||
|
||||
result = honeywell.setup_platform(hass, config, add_entities)
|
||||
self.assertTrue(result)
|
||||
self.assertEqual(mock_sc.call_count, 1)
|
||||
self.assertEqual(mock_sc.call_args, mock.call('user', 'pass'))
|
||||
assert result
|
||||
assert mock_sc.call_count == 1
|
||||
assert mock_sc.call_args == mock.call('user', 'pass')
|
||||
mock_ht.assert_has_calls([
|
||||
mock.call(mock_sc.return_value, devices_1[0], 18, 28,
|
||||
'user', 'pass'),
|
||||
@@ -95,13 +96,13 @@ class TestHoneywell(unittest.TestCase):
|
||||
|
||||
mock_sc.side_effect = somecomfort.AuthError
|
||||
result = honeywell.setup_platform(hass, config, add_entities)
|
||||
self.assertFalse(result)
|
||||
self.assertFalse(add_entities.called)
|
||||
assert not result
|
||||
assert not add_entities.called
|
||||
|
||||
mock_sc.side_effect = somecomfort.SomeComfortError
|
||||
result = honeywell.setup_platform(hass, config, add_entities)
|
||||
self.assertFalse(result)
|
||||
self.assertFalse(add_entities.called)
|
||||
assert not result
|
||||
assert not add_entities.called
|
||||
|
||||
@mock.patch('somecomfort.SomeComfort')
|
||||
@mock.patch('homeassistant.components.climate.'
|
||||
@@ -137,8 +138,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
mock_sc.return_value = mock.MagicMock(locations_by_id=locations)
|
||||
hass = mock.MagicMock()
|
||||
add_entities = mock.MagicMock()
|
||||
self.assertEqual(True,
|
||||
honeywell.setup_platform(hass, config, add_entities))
|
||||
assert honeywell.setup_platform(hass, config, add_entities) is True
|
||||
|
||||
return mock_ht.call_args_list, mock_sc
|
||||
|
||||
@@ -147,29 +147,28 @@ class TestHoneywell(unittest.TestCase):
|
||||
result, client = self._test_us_filtered_devices(
|
||||
dev=mock.sentinel.loc1dev1)
|
||||
devices = [x[0][1].deviceid for x in result]
|
||||
self.assertEqual([mock.sentinel.loc1dev1], devices)
|
||||
assert [mock.sentinel.loc1dev1] == devices
|
||||
|
||||
def test_us_filtered_thermostat_2(self):
|
||||
"""Test for US filtered location."""
|
||||
result, client = self._test_us_filtered_devices(
|
||||
dev=mock.sentinel.loc2dev1)
|
||||
devices = [x[0][1].deviceid for x in result]
|
||||
self.assertEqual([mock.sentinel.loc2dev1], devices)
|
||||
assert [mock.sentinel.loc2dev1] == devices
|
||||
|
||||
def test_us_filtered_location_1(self):
|
||||
"""Test for US filtered locations."""
|
||||
result, client = self._test_us_filtered_devices(
|
||||
loc=mock.sentinel.loc1)
|
||||
devices = [x[0][1].deviceid for x in result]
|
||||
self.assertEqual([mock.sentinel.loc1dev1,
|
||||
mock.sentinel.loc1dev2], devices)
|
||||
assert [mock.sentinel.loc1dev1, mock.sentinel.loc1dev2] == devices
|
||||
|
||||
def test_us_filtered_location_2(self):
|
||||
"""Test for US filtered locations."""
|
||||
result, client = self._test_us_filtered_devices(
|
||||
loc=mock.sentinel.loc2)
|
||||
devices = [x[0][1].deviceid for x in result]
|
||||
self.assertEqual([mock.sentinel.loc2dev1], devices)
|
||||
assert [mock.sentinel.loc2dev1] == devices
|
||||
|
||||
@mock.patch('evohomeclient.EvohomeClient')
|
||||
@mock.patch('homeassistant.components.climate.honeywell.'
|
||||
@@ -186,19 +185,17 @@ class TestHoneywell(unittest.TestCase):
|
||||
{'id': 'foo'}, {'id': 'bar'}]
|
||||
hass = mock.MagicMock()
|
||||
add_entities = mock.MagicMock()
|
||||
self.assertTrue(honeywell.setup_platform(hass, config, add_entities))
|
||||
self.assertEqual(mock_evo.call_count, 1)
|
||||
self.assertEqual(mock_evo.call_args, mock.call('user', 'pass'))
|
||||
self.assertEqual(mock_evo.return_value.temperatures.call_count, 1)
|
||||
self.assertEqual(
|
||||
mock_evo.return_value.temperatures.call_args,
|
||||
assert honeywell.setup_platform(hass, config, add_entities)
|
||||
assert mock_evo.call_count == 1
|
||||
assert mock_evo.call_args == mock.call('user', 'pass')
|
||||
assert mock_evo.return_value.temperatures.call_count == 1
|
||||
assert mock_evo.return_value.temperatures.call_args == \
|
||||
mock.call(force_refresh=True)
|
||||
)
|
||||
mock_round.assert_has_calls([
|
||||
mock.call(mock_evo.return_value, 'foo', True, 20.0),
|
||||
mock.call(mock_evo.return_value, 'bar', False, 20.0),
|
||||
])
|
||||
self.assertEqual(2, add_entities.call_count)
|
||||
assert 2 == add_entities.call_count
|
||||
|
||||
@mock.patch('evohomeclient.EvohomeClient')
|
||||
@mock.patch('homeassistant.components.climate.honeywell.'
|
||||
@@ -218,7 +215,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
|
||||
hass = mock.MagicMock()
|
||||
add_entities = mock.MagicMock()
|
||||
self.assertTrue(honeywell.setup_platform(hass, config, add_entities))
|
||||
assert honeywell.setup_platform(hass, config, add_entities)
|
||||
mock_round.assert_has_calls([
|
||||
mock.call(mock_evo.return_value, 'foo', True, 16),
|
||||
mock.call(mock_evo.return_value, 'bar', False, 16),
|
||||
@@ -236,7 +233,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
honeywell.CONF_REGION: 'eu',
|
||||
}
|
||||
|
||||
with self.assertRaises(vol.Invalid):
|
||||
with pytest.raises(vol.Invalid):
|
||||
honeywell.PLATFORM_SCHEMA(config)
|
||||
|
||||
@mock.patch('evohomeclient.EvohomeClient')
|
||||
@@ -253,7 +250,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
mock_evo.return_value.temperatures.side_effect = socket.error
|
||||
add_entities = mock.MagicMock()
|
||||
hass = mock.MagicMock()
|
||||
self.assertFalse(honeywell.setup_platform(hass, config, add_entities))
|
||||
assert not honeywell.setup_platform(hass, config, add_entities)
|
||||
|
||||
|
||||
class TestHoneywellRound(unittest.TestCase):
|
||||
@@ -282,53 +279,47 @@ class TestHoneywellRound(unittest.TestCase):
|
||||
|
||||
def test_attributes(self):
|
||||
"""Test the attributes."""
|
||||
self.assertEqual('House', self.round1.name)
|
||||
self.assertEqual(TEMP_CELSIUS, self.round1.temperature_unit)
|
||||
self.assertEqual(20, self.round1.current_temperature)
|
||||
self.assertEqual(21, self.round1.target_temperature)
|
||||
self.assertFalse(self.round1.is_away_mode_on)
|
||||
assert 'House' == self.round1.name
|
||||
assert TEMP_CELSIUS == self.round1.temperature_unit
|
||||
assert 20 == self.round1.current_temperature
|
||||
assert 21 == self.round1.target_temperature
|
||||
assert not self.round1.is_away_mode_on
|
||||
|
||||
self.assertEqual('Hot Water', self.round2.name)
|
||||
self.assertEqual(TEMP_CELSIUS, self.round2.temperature_unit)
|
||||
self.assertEqual(21, self.round2.current_temperature)
|
||||
self.assertEqual(None, self.round2.target_temperature)
|
||||
self.assertFalse(self.round2.is_away_mode_on)
|
||||
assert 'Hot Water' == self.round2.name
|
||||
assert TEMP_CELSIUS == self.round2.temperature_unit
|
||||
assert 21 == self.round2.current_temperature
|
||||
assert self.round2.target_temperature is None
|
||||
assert not self.round2.is_away_mode_on
|
||||
|
||||
def test_away_mode(self):
|
||||
"""Test setting the away mode."""
|
||||
self.assertFalse(self.round1.is_away_mode_on)
|
||||
assert not self.round1.is_away_mode_on
|
||||
self.round1.turn_away_mode_on()
|
||||
self.assertTrue(self.round1.is_away_mode_on)
|
||||
self.assertEqual(self.device.set_temperature.call_count, 1)
|
||||
self.assertEqual(
|
||||
self.device.set_temperature.call_args, mock.call('House', 16)
|
||||
)
|
||||
assert self.round1.is_away_mode_on
|
||||
assert self.device.set_temperature.call_count == 1
|
||||
assert self.device.set_temperature.call_args == mock.call('House', 16)
|
||||
|
||||
self.device.set_temperature.reset_mock()
|
||||
self.round1.turn_away_mode_off()
|
||||
self.assertFalse(self.round1.is_away_mode_on)
|
||||
self.assertEqual(self.device.cancel_temp_override.call_count, 1)
|
||||
self.assertEqual(
|
||||
self.device.cancel_temp_override.call_args, mock.call('House')
|
||||
)
|
||||
assert not self.round1.is_away_mode_on
|
||||
assert self.device.cancel_temp_override.call_count == 1
|
||||
assert self.device.cancel_temp_override.call_args == mock.call('House')
|
||||
|
||||
def test_set_temperature(self):
|
||||
"""Test setting the temperature."""
|
||||
self.round1.set_temperature(temperature=25)
|
||||
self.assertEqual(self.device.set_temperature.call_count, 1)
|
||||
self.assertEqual(
|
||||
self.device.set_temperature.call_args, mock.call('House', 25)
|
||||
)
|
||||
assert self.device.set_temperature.call_count == 1
|
||||
assert self.device.set_temperature.call_args == mock.call('House', 25)
|
||||
|
||||
def test_set_operation_mode(self) -> None:
|
||||
"""Test setting the system operation."""
|
||||
self.round1.set_operation_mode('cool')
|
||||
self.assertEqual('cool', self.round1.current_operation)
|
||||
self.assertEqual('cool', self.device.system_mode)
|
||||
assert 'cool' == self.round1.current_operation
|
||||
assert 'cool' == self.device.system_mode
|
||||
|
||||
self.round1.set_operation_mode('heat')
|
||||
self.assertEqual('heat', self.round1.current_operation)
|
||||
self.assertEqual('heat', self.device.system_mode)
|
||||
assert 'heat' == self.round1.current_operation
|
||||
assert 'heat' == self.device.system_mode
|
||||
|
||||
|
||||
class TestHoneywellUS(unittest.TestCase):
|
||||
@@ -356,41 +347,41 @@ class TestHoneywellUS(unittest.TestCase):
|
||||
|
||||
def test_properties(self):
|
||||
"""Test the properties."""
|
||||
self.assertTrue(self.honeywell.is_fan_on)
|
||||
self.assertEqual('test', self.honeywell.name)
|
||||
self.assertEqual(72, self.honeywell.current_temperature)
|
||||
assert self.honeywell.is_fan_on
|
||||
assert 'test' == self.honeywell.name
|
||||
assert 72 == self.honeywell.current_temperature
|
||||
|
||||
def test_unit_of_measurement(self):
|
||||
"""Test the unit of measurement."""
|
||||
self.assertEqual(TEMP_FAHRENHEIT, self.honeywell.temperature_unit)
|
||||
assert TEMP_FAHRENHEIT == self.honeywell.temperature_unit
|
||||
self.device.temperature_unit = 'C'
|
||||
self.assertEqual(TEMP_CELSIUS, self.honeywell.temperature_unit)
|
||||
assert TEMP_CELSIUS == self.honeywell.temperature_unit
|
||||
|
||||
def test_target_temp(self):
|
||||
"""Test the target temperature."""
|
||||
self.assertEqual(65, self.honeywell.target_temperature)
|
||||
assert 65 == self.honeywell.target_temperature
|
||||
self.device.system_mode = 'cool'
|
||||
self.assertEqual(78, self.honeywell.target_temperature)
|
||||
assert 78 == self.honeywell.target_temperature
|
||||
|
||||
def test_set_temp(self):
|
||||
"""Test setting the temperature."""
|
||||
self.honeywell.set_temperature(temperature=70)
|
||||
self.assertEqual(70, self.device.setpoint_heat)
|
||||
self.assertEqual(70, self.honeywell.target_temperature)
|
||||
assert 70 == self.device.setpoint_heat
|
||||
assert 70 == self.honeywell.target_temperature
|
||||
|
||||
self.device.system_mode = 'cool'
|
||||
self.assertEqual(78, self.honeywell.target_temperature)
|
||||
assert 78 == self.honeywell.target_temperature
|
||||
self.honeywell.set_temperature(temperature=74)
|
||||
self.assertEqual(74, self.device.setpoint_cool)
|
||||
self.assertEqual(74, self.honeywell.target_temperature)
|
||||
assert 74 == self.device.setpoint_cool
|
||||
assert 74 == self.honeywell.target_temperature
|
||||
|
||||
def test_set_operation_mode(self) -> None:
|
||||
"""Test setting the operation mode."""
|
||||
self.honeywell.set_operation_mode('cool')
|
||||
self.assertEqual('cool', self.device.system_mode)
|
||||
assert 'cool' == self.device.system_mode
|
||||
|
||||
self.honeywell.set_operation_mode('heat')
|
||||
self.assertEqual('heat', self.device.system_mode)
|
||||
assert 'heat' == self.device.system_mode
|
||||
|
||||
def test_set_temp_fail(self):
|
||||
"""Test if setting the temperature fails."""
|
||||
@@ -407,10 +398,10 @@ class TestHoneywellUS(unittest.TestCase):
|
||||
ATTR_FAN_LIST: somecomfort.FAN_MODES,
|
||||
ATTR_OPERATION_LIST: somecomfort.SYSTEM_MODES,
|
||||
}
|
||||
self.assertEqual(expected, self.honeywell.device_state_attributes)
|
||||
assert expected == self.honeywell.device_state_attributes
|
||||
expected['fan'] = 'idle'
|
||||
self.device.fan_running = False
|
||||
self.assertEqual(expected, self.honeywell.device_state_attributes)
|
||||
assert expected == self.honeywell.device_state_attributes
|
||||
|
||||
def test_with_no_fan(self):
|
||||
"""Test if there is on fan."""
|
||||
@@ -423,24 +414,24 @@ class TestHoneywellUS(unittest.TestCase):
|
||||
ATTR_FAN_LIST: somecomfort.FAN_MODES,
|
||||
ATTR_OPERATION_LIST: somecomfort.SYSTEM_MODES,
|
||||
}
|
||||
self.assertEqual(expected, self.honeywell.device_state_attributes)
|
||||
assert expected == self.honeywell.device_state_attributes
|
||||
|
||||
def test_heat_away_mode(self):
|
||||
"""Test setting the heat away mode."""
|
||||
self.honeywell.set_operation_mode('heat')
|
||||
self.assertFalse(self.honeywell.is_away_mode_on)
|
||||
assert not self.honeywell.is_away_mode_on
|
||||
self.honeywell.turn_away_mode_on()
|
||||
self.assertTrue(self.honeywell.is_away_mode_on)
|
||||
self.assertEqual(self.device.setpoint_heat, self.heat_away_temp)
|
||||
self.assertEqual(self.device.hold_heat, True)
|
||||
assert self.honeywell.is_away_mode_on
|
||||
assert self.device.setpoint_heat == self.heat_away_temp
|
||||
assert self.device.hold_heat is True
|
||||
|
||||
self.honeywell.turn_away_mode_off()
|
||||
self.assertFalse(self.honeywell.is_away_mode_on)
|
||||
self.assertEqual(self.device.hold_heat, False)
|
||||
assert not self.honeywell.is_away_mode_on
|
||||
assert self.device.hold_heat is False
|
||||
|
||||
@mock.patch('somecomfort.SomeComfort')
|
||||
def test_retry(self, test_somecomfort):
|
||||
"""Test retry connection."""
|
||||
old_device = self.honeywell._device
|
||||
self.honeywell._retry()
|
||||
self.assertEqual(self.honeywell._device, old_device)
|
||||
assert self.honeywell._device == old_device
|
||||
@@ -84,133 +84,129 @@ class TestMelissa(unittest.TestCase):
|
||||
|
||||
def test_get_name(self):
|
||||
"""Test name property."""
|
||||
self.assertEqual("Melissa 12345678", self.thermostat.name)
|
||||
assert "Melissa 12345678" == self.thermostat.name
|
||||
|
||||
def test_is_on(self):
|
||||
"""Test name property."""
|
||||
self.assertTrue(self.thermostat.is_on)
|
||||
assert self.thermostat.is_on
|
||||
self.thermostat._cur_settings = None
|
||||
self.assertFalse(self.thermostat.is_on)
|
||||
assert not self.thermostat.is_on
|
||||
|
||||
def test_current_fan_mode(self):
|
||||
"""Test current_fan_mode property."""
|
||||
self.thermostat.update()
|
||||
self.assertEqual(SPEED_LOW, self.thermostat.current_fan_mode)
|
||||
assert SPEED_LOW == self.thermostat.current_fan_mode
|
||||
self.thermostat._cur_settings = None
|
||||
self.assertEqual(None, self.thermostat.current_fan_mode)
|
||||
assert self.thermostat.current_fan_mode is None
|
||||
|
||||
def test_current_temperature(self):
|
||||
"""Test current temperature."""
|
||||
self.assertEqual(27.4, self.thermostat.current_temperature)
|
||||
assert 27.4 == self.thermostat.current_temperature
|
||||
|
||||
def test_current_temperature_no_data(self):
|
||||
"""Test current temperature without data."""
|
||||
self.thermostat._data = None
|
||||
self.assertIsNone(self.thermostat.current_temperature)
|
||||
assert self.thermostat.current_temperature is None
|
||||
|
||||
def test_target_temperature_step(self):
|
||||
"""Test current target_temperature_step."""
|
||||
self.assertEqual(1, self.thermostat.target_temperature_step)
|
||||
assert 1 == self.thermostat.target_temperature_step
|
||||
|
||||
def test_current_operation(self):
|
||||
"""Test current operation."""
|
||||
self.thermostat.update()
|
||||
self.assertEqual(self.thermostat.current_operation, STATE_HEAT)
|
||||
assert self.thermostat.current_operation == STATE_HEAT
|
||||
self.thermostat._cur_settings = None
|
||||
self.assertEqual(None, self.thermostat.current_operation)
|
||||
assert self.thermostat.current_operation is None
|
||||
|
||||
def test_operation_list(self):
|
||||
"""Test the operation list."""
|
||||
self.assertEqual(
|
||||
[STATE_COOL, STATE_DRY, STATE_FAN_ONLY, STATE_HEAT],
|
||||
assert [STATE_COOL, STATE_DRY, STATE_FAN_ONLY, STATE_HEAT] == \
|
||||
self.thermostat.operation_list
|
||||
)
|
||||
|
||||
def test_fan_list(self):
|
||||
"""Test the fan list."""
|
||||
self.assertEqual(
|
||||
[STATE_AUTO, SPEED_HIGH, SPEED_LOW, SPEED_MEDIUM],
|
||||
assert [STATE_AUTO, SPEED_HIGH, SPEED_LOW, SPEED_MEDIUM] == \
|
||||
self.thermostat.fan_list
|
||||
)
|
||||
|
||||
def test_target_temperature(self):
|
||||
"""Test target temperature."""
|
||||
self.assertEqual(16, self.thermostat.target_temperature)
|
||||
assert 16 == self.thermostat.target_temperature
|
||||
self.thermostat._cur_settings = None
|
||||
self.assertEqual(None, self.thermostat.target_temperature)
|
||||
assert self.thermostat.target_temperature is None
|
||||
|
||||
def test_state(self):
|
||||
"""Test state."""
|
||||
self.assertEqual(STATE_ON, self.thermostat.state)
|
||||
assert STATE_ON == self.thermostat.state
|
||||
self.thermostat._cur_settings = None
|
||||
self.assertEqual(None, self.thermostat.state)
|
||||
assert self.thermostat.state is None
|
||||
|
||||
def test_temperature_unit(self):
|
||||
"""Test temperature unit."""
|
||||
self.assertEqual(TEMP_CELSIUS, self.thermostat.temperature_unit)
|
||||
assert TEMP_CELSIUS == self.thermostat.temperature_unit
|
||||
|
||||
def test_min_temp(self):
|
||||
"""Test min temp."""
|
||||
self.assertEqual(16, self.thermostat.min_temp)
|
||||
assert 16 == self.thermostat.min_temp
|
||||
|
||||
def test_max_temp(self):
|
||||
"""Test max temp."""
|
||||
self.assertEqual(30, self.thermostat.max_temp)
|
||||
assert 30 == self.thermostat.max_temp
|
||||
|
||||
def test_supported_features(self):
|
||||
"""Test supported_features property."""
|
||||
features = (SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE |
|
||||
SUPPORT_ON_OFF | SUPPORT_FAN_MODE)
|
||||
self.assertEqual(features, self.thermostat.supported_features)
|
||||
assert features == self.thermostat.supported_features
|
||||
|
||||
def test_set_temperature(self):
|
||||
"""Test set_temperature."""
|
||||
self.api.send.return_value = True
|
||||
self.thermostat.update()
|
||||
self.thermostat.set_temperature(**{ATTR_TEMPERATURE: 25})
|
||||
self.assertEqual(25, self.thermostat.target_temperature)
|
||||
assert 25 == self.thermostat.target_temperature
|
||||
|
||||
def test_fan_mode(self):
|
||||
"""Test set_fan_mode."""
|
||||
self.api.send.return_value = True
|
||||
self.thermostat.set_fan_mode(SPEED_HIGH)
|
||||
self.assertEqual(SPEED_HIGH, self.thermostat.current_fan_mode)
|
||||
assert SPEED_HIGH == self.thermostat.current_fan_mode
|
||||
|
||||
def test_set_operation_mode(self):
|
||||
"""Test set_operation_mode."""
|
||||
self.api.send.return_value = True
|
||||
self.thermostat.set_operation_mode(STATE_COOL)
|
||||
self.assertEqual(STATE_COOL, self.thermostat.current_operation)
|
||||
assert STATE_COOL == self.thermostat.current_operation
|
||||
|
||||
def test_turn_on(self):
|
||||
"""Test turn_on."""
|
||||
self.thermostat.turn_on()
|
||||
self.assertTrue(self.thermostat.state)
|
||||
assert self.thermostat.state
|
||||
|
||||
def test_turn_off(self):
|
||||
"""Test turn_off."""
|
||||
self.thermostat.turn_off()
|
||||
self.assertEqual(STATE_OFF, self.thermostat.state)
|
||||
assert STATE_OFF == self.thermostat.state
|
||||
|
||||
def test_send(self):
|
||||
"""Test send."""
|
||||
self.thermostat.update()
|
||||
self.assertTrue(self.thermostat.send(
|
||||
{'fan': self.api.FAN_MEDIUM}))
|
||||
self.assertEqual(SPEED_MEDIUM, self.thermostat.current_fan_mode)
|
||||
assert self.thermostat.send(
|
||||
{'fan': self.api.FAN_MEDIUM})
|
||||
assert SPEED_MEDIUM == self.thermostat.current_fan_mode
|
||||
self.api.send.return_value = False
|
||||
self.thermostat._cur_settings = None
|
||||
self.assertFalse(self.thermostat.send({
|
||||
'fan': self.api.FAN_LOW}))
|
||||
self.assertNotEqual(SPEED_LOW, self.thermostat.current_fan_mode)
|
||||
self.assertIsNone(self.thermostat._cur_settings)
|
||||
assert not self.thermostat.send({
|
||||
'fan': self.api.FAN_LOW})
|
||||
assert SPEED_LOW != self.thermostat.current_fan_mode
|
||||
assert self.thermostat._cur_settings is None
|
||||
|
||||
@mock.patch('homeassistant.components.climate.melissa._LOGGER.warning')
|
||||
def test_update(self, mocked_warning):
|
||||
"""Test update."""
|
||||
self.thermostat.update()
|
||||
self.assertEqual(SPEED_LOW, self.thermostat.current_fan_mode)
|
||||
self.assertEqual(STATE_HEAT, self.thermostat.current_operation)
|
||||
assert SPEED_LOW == self.thermostat.current_fan_mode
|
||||
assert STATE_HEAT == self.thermostat.current_operation
|
||||
self.thermostat._api.status.side_effect = KeyError('boom')
|
||||
self.thermostat.update()
|
||||
mocked_warning.assert_called_once_with(
|
||||
@@ -218,37 +214,34 @@ class TestMelissa(unittest.TestCase):
|
||||
|
||||
def test_melissa_state_to_hass(self):
|
||||
"""Test for translate melissa states to hass."""
|
||||
self.assertEqual(STATE_OFF, self.thermostat.melissa_state_to_hass(0))
|
||||
self.assertEqual(STATE_ON, self.thermostat.melissa_state_to_hass(1))
|
||||
self.assertEqual(STATE_IDLE, self.thermostat.melissa_state_to_hass(2))
|
||||
self.assertEqual(None,
|
||||
self.thermostat.melissa_state_to_hass(3))
|
||||
assert STATE_OFF == self.thermostat.melissa_state_to_hass(0)
|
||||
assert STATE_ON == self.thermostat.melissa_state_to_hass(1)
|
||||
assert STATE_IDLE == self.thermostat.melissa_state_to_hass(2)
|
||||
assert self.thermostat.melissa_state_to_hass(3) is None
|
||||
|
||||
def test_melissa_op_to_hass(self):
|
||||
"""Test for translate melissa operations to hass."""
|
||||
self.assertEqual(STATE_FAN_ONLY, self.thermostat.melissa_op_to_hass(1))
|
||||
self.assertEqual(STATE_HEAT, self.thermostat.melissa_op_to_hass(2))
|
||||
self.assertEqual(STATE_COOL, self.thermostat.melissa_op_to_hass(3))
|
||||
self.assertEqual(STATE_DRY, self.thermostat.melissa_op_to_hass(4))
|
||||
self.assertEqual(
|
||||
None, self.thermostat.melissa_op_to_hass(5))
|
||||
assert STATE_FAN_ONLY == self.thermostat.melissa_op_to_hass(1)
|
||||
assert STATE_HEAT == self.thermostat.melissa_op_to_hass(2)
|
||||
assert STATE_COOL == self.thermostat.melissa_op_to_hass(3)
|
||||
assert STATE_DRY == self.thermostat.melissa_op_to_hass(4)
|
||||
assert self.thermostat.melissa_op_to_hass(5) is None
|
||||
|
||||
def test_melissa_fan_to_hass(self):
|
||||
"""Test for translate melissa fan state to hass."""
|
||||
self.assertEqual(STATE_AUTO, self.thermostat.melissa_fan_to_hass(0))
|
||||
self.assertEqual(SPEED_LOW, self.thermostat.melissa_fan_to_hass(1))
|
||||
self.assertEqual(SPEED_MEDIUM, self.thermostat.melissa_fan_to_hass(2))
|
||||
self.assertEqual(SPEED_HIGH, self.thermostat.melissa_fan_to_hass(3))
|
||||
self.assertEqual(None, self.thermostat.melissa_fan_to_hass(4))
|
||||
assert STATE_AUTO == self.thermostat.melissa_fan_to_hass(0)
|
||||
assert SPEED_LOW == self.thermostat.melissa_fan_to_hass(1)
|
||||
assert SPEED_MEDIUM == self.thermostat.melissa_fan_to_hass(2)
|
||||
assert SPEED_HIGH == self.thermostat.melissa_fan_to_hass(3)
|
||||
assert self.thermostat.melissa_fan_to_hass(4) is None
|
||||
|
||||
@mock.patch('homeassistant.components.climate.melissa._LOGGER.warning')
|
||||
def test_hass_mode_to_melissa(self, mocked_warning):
|
||||
"""Test for hass operations to melssa."""
|
||||
self.assertEqual(
|
||||
1, self.thermostat.hass_mode_to_melissa(STATE_FAN_ONLY))
|
||||
self.assertEqual(2, self.thermostat.hass_mode_to_melissa(STATE_HEAT))
|
||||
self.assertEqual(3, self.thermostat.hass_mode_to_melissa(STATE_COOL))
|
||||
self.assertEqual(4, self.thermostat.hass_mode_to_melissa(STATE_DRY))
|
||||
assert 1 == self.thermostat.hass_mode_to_melissa(STATE_FAN_ONLY)
|
||||
assert 2 == self.thermostat.hass_mode_to_melissa(STATE_HEAT)
|
||||
assert 3 == self.thermostat.hass_mode_to_melissa(STATE_COOL)
|
||||
assert 4 == self.thermostat.hass_mode_to_melissa(STATE_DRY)
|
||||
self.thermostat.hass_mode_to_melissa("test")
|
||||
mocked_warning.assert_called_once_with(
|
||||
"Melissa have no setting for %s mode", "test")
|
||||
@@ -256,10 +249,10 @@ class TestMelissa(unittest.TestCase):
|
||||
@mock.patch('homeassistant.components.climate.melissa._LOGGER.warning')
|
||||
def test_hass_fan_to_melissa(self, mocked_warning):
|
||||
"""Test for translate melissa states to hass."""
|
||||
self.assertEqual(0, self.thermostat.hass_fan_to_melissa(STATE_AUTO))
|
||||
self.assertEqual(1, self.thermostat.hass_fan_to_melissa(SPEED_LOW))
|
||||
self.assertEqual(2, self.thermostat.hass_fan_to_melissa(SPEED_MEDIUM))
|
||||
self.assertEqual(3, self.thermostat.hass_fan_to_melissa(SPEED_HIGH))
|
||||
assert 0 == self.thermostat.hass_fan_to_melissa(STATE_AUTO)
|
||||
assert 1 == self.thermostat.hass_fan_to_melissa(SPEED_LOW)
|
||||
assert 2 == self.thermostat.hass_fan_to_melissa(SPEED_MEDIUM)
|
||||
assert 3 == self.thermostat.hass_fan_to_melissa(SPEED_HIGH)
|
||||
self.thermostat.hass_fan_to_melissa("test")
|
||||
mocked_warning.assert_called_once_with(
|
||||
"Melissa have no setting for %s fan mode", "test")
|
||||
@@ -52,12 +52,12 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(21, state.attributes.get('temperature'))
|
||||
self.assertEqual("low", state.attributes.get('fan_mode'))
|
||||
self.assertEqual("off", state.attributes.get('swing_mode'))
|
||||
self.assertEqual("off", state.attributes.get('operation_mode'))
|
||||
self.assertEqual(DEFAULT_MIN_TEMP, state.attributes.get('min_temp'))
|
||||
self.assertEqual(DEFAULT_MAX_TEMP, state.attributes.get('max_temp'))
|
||||
assert 21 == state.attributes.get('temperature')
|
||||
assert "low" == state.attributes.get('fan_mode')
|
||||
assert "off" == state.attributes.get('swing_mode')
|
||||
assert "off" == state.attributes.get('operation_mode')
|
||||
assert DEFAULT_MIN_TEMP == state.attributes.get('min_temp')
|
||||
assert DEFAULT_MAX_TEMP == state.attributes.get('max_temp')
|
||||
|
||||
def test_supported_features(self):
|
||||
"""Test the supported_features."""
|
||||
@@ -68,7 +68,7 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
SUPPORT_SWING_MODE | SUPPORT_FAN_MODE | SUPPORT_AWAY_MODE |
|
||||
SUPPORT_HOLD_MODE | SUPPORT_AUX_HEAT)
|
||||
|
||||
self.assertEqual(state.attributes.get("supported_features"), support)
|
||||
assert state.attributes.get("supported_features") == support
|
||||
|
||||
def test_get_operation_modes(self):
|
||||
"""Test that the operation list returns the correct modes."""
|
||||
@@ -76,10 +76,10 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
modes = state.attributes.get('operation_list')
|
||||
self.assertEqual([
|
||||
assert [
|
||||
climate.STATE_AUTO, STATE_OFF, climate.STATE_COOL,
|
||||
climate.STATE_HEAT, climate.STATE_DRY, climate.STATE_FAN_ONLY
|
||||
], modes)
|
||||
] == modes
|
||||
|
||||
def test_set_operation_bad_attr_and_state(self):
|
||||
"""Test setting operation mode without required attribute.
|
||||
@@ -89,26 +89,26 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("off", state.attributes.get('operation_mode'))
|
||||
self.assertEqual("off", state.state)
|
||||
assert "off" == state.attributes.get('operation_mode')
|
||||
assert "off" == state.state
|
||||
common.set_operation_mode(self.hass, None, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("off", state.attributes.get('operation_mode'))
|
||||
self.assertEqual("off", state.state)
|
||||
assert "off" == state.attributes.get('operation_mode')
|
||||
assert "off" == state.state
|
||||
|
||||
def test_set_operation(self):
|
||||
"""Test setting of new operation mode."""
|
||||
assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("off", state.attributes.get('operation_mode'))
|
||||
self.assertEqual("off", state.state)
|
||||
assert "off" == state.attributes.get('operation_mode')
|
||||
assert "off" == state.state
|
||||
common.set_operation_mode(self.hass, "cool", ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("cool", state.attributes.get('operation_mode'))
|
||||
self.assertEqual("cool", state.state)
|
||||
assert "cool" == state.attributes.get('operation_mode')
|
||||
assert "cool" == state.state
|
||||
self.mock_publish.async_publish.assert_called_once_with(
|
||||
'mode-topic', 'cool', 0, False)
|
||||
|
||||
@@ -119,26 +119,26 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
assert setup_component(self.hass, climate.DOMAIN, config)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(None, state.attributes.get('operation_mode'))
|
||||
self.assertEqual("unknown", state.state)
|
||||
assert state.attributes.get('operation_mode') is None
|
||||
assert "unknown" == state.state
|
||||
|
||||
common.set_operation_mode(self.hass, "cool", ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(None, state.attributes.get('operation_mode'))
|
||||
self.assertEqual("unknown", state.state)
|
||||
assert state.attributes.get('operation_mode') is None
|
||||
assert "unknown" == state.state
|
||||
|
||||
fire_mqtt_message(self.hass, 'mode-state', 'cool')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("cool", state.attributes.get('operation_mode'))
|
||||
self.assertEqual("cool", state.state)
|
||||
assert "cool" == state.attributes.get('operation_mode')
|
||||
assert "cool" == state.state
|
||||
|
||||
fire_mqtt_message(self.hass, 'mode-state', 'bogus mode')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("cool", state.attributes.get('operation_mode'))
|
||||
self.assertEqual("cool", state.state)
|
||||
assert "cool" == state.attributes.get('operation_mode')
|
||||
assert "cool" == state.state
|
||||
|
||||
def test_set_operation_with_power_command(self):
|
||||
"""Test setting of new operation mode with power command enabled."""
|
||||
@@ -147,13 +147,13 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
assert setup_component(self.hass, climate.DOMAIN, config)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("off", state.attributes.get('operation_mode'))
|
||||
self.assertEqual("off", state.state)
|
||||
assert "off" == state.attributes.get('operation_mode')
|
||||
assert "off" == state.state
|
||||
common.set_operation_mode(self.hass, "on", ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("on", state.attributes.get('operation_mode'))
|
||||
self.assertEqual("on", state.state)
|
||||
assert "on" == state.attributes.get('operation_mode')
|
||||
assert "on" == state.state
|
||||
self.mock_publish.async_publish.assert_has_calls([
|
||||
unittest.mock.call('power-command', 'ON', 0, False),
|
||||
unittest.mock.call('mode-topic', 'on', 0, False)
|
||||
@@ -163,8 +163,8 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
common.set_operation_mode(self.hass, "off", ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("off", state.attributes.get('operation_mode'))
|
||||
self.assertEqual("off", state.state)
|
||||
assert "off" == state.attributes.get('operation_mode')
|
||||
assert "off" == state.state
|
||||
self.mock_publish.async_publish.assert_has_calls([
|
||||
unittest.mock.call('power-command', 'OFF', 0, False),
|
||||
unittest.mock.call('mode-topic', 'off', 0, False)
|
||||
@@ -176,11 +176,11 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("low", state.attributes.get('fan_mode'))
|
||||
assert "low" == state.attributes.get('fan_mode')
|
||||
common.set_fan_mode(self.hass, None, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("low", state.attributes.get('fan_mode'))
|
||||
assert "low" == state.attributes.get('fan_mode')
|
||||
|
||||
def test_set_fan_mode_pessimistic(self):
|
||||
"""Test setting of new fan mode in pessimistic mode."""
|
||||
@@ -189,46 +189,46 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
assert setup_component(self.hass, climate.DOMAIN, config)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(None, state.attributes.get('fan_mode'))
|
||||
assert state.attributes.get('fan_mode') is None
|
||||
|
||||
common.set_fan_mode(self.hass, 'high', ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(None, state.attributes.get('fan_mode'))
|
||||
assert state.attributes.get('fan_mode') is None
|
||||
|
||||
fire_mqtt_message(self.hass, 'fan-state', 'high')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('high', state.attributes.get('fan_mode'))
|
||||
assert 'high' == state.attributes.get('fan_mode')
|
||||
|
||||
fire_mqtt_message(self.hass, 'fan-state', 'bogus mode')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('high', state.attributes.get('fan_mode'))
|
||||
assert 'high' == state.attributes.get('fan_mode')
|
||||
|
||||
def test_set_fan_mode(self):
|
||||
"""Test setting of new fan mode."""
|
||||
assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("low", state.attributes.get('fan_mode'))
|
||||
assert "low" == state.attributes.get('fan_mode')
|
||||
common.set_fan_mode(self.hass, 'high', ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
self.mock_publish.async_publish.assert_called_once_with(
|
||||
'fan-mode-topic', 'high', 0, False)
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('high', state.attributes.get('fan_mode'))
|
||||
assert 'high' == state.attributes.get('fan_mode')
|
||||
|
||||
def test_set_swing_mode_bad_attr(self):
|
||||
"""Test setting swing mode without required attribute."""
|
||||
assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("off", state.attributes.get('swing_mode'))
|
||||
assert "off" == state.attributes.get('swing_mode')
|
||||
common.set_swing_mode(self.hass, None, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("off", state.attributes.get('swing_mode'))
|
||||
assert "off" == state.attributes.get('swing_mode')
|
||||
|
||||
def test_set_swing_pessimistic(self):
|
||||
"""Test setting swing mode in pessimistic mode."""
|
||||
@@ -237,46 +237,46 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
assert setup_component(self.hass, climate.DOMAIN, config)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(None, state.attributes.get('swing_mode'))
|
||||
assert state.attributes.get('swing_mode') is None
|
||||
|
||||
common.set_swing_mode(self.hass, 'on', ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(None, state.attributes.get('swing_mode'))
|
||||
assert state.attributes.get('swing_mode') is None
|
||||
|
||||
fire_mqtt_message(self.hass, 'swing-state', 'on')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("on", state.attributes.get('swing_mode'))
|
||||
assert "on" == state.attributes.get('swing_mode')
|
||||
|
||||
fire_mqtt_message(self.hass, 'swing-state', 'bogus state')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("on", state.attributes.get('swing_mode'))
|
||||
assert "on" == state.attributes.get('swing_mode')
|
||||
|
||||
def test_set_swing(self):
|
||||
"""Test setting of new swing mode."""
|
||||
assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("off", state.attributes.get('swing_mode'))
|
||||
assert "off" == state.attributes.get('swing_mode')
|
||||
common.set_swing_mode(self.hass, 'on', ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
self.mock_publish.async_publish.assert_called_once_with(
|
||||
'swing-mode-topic', 'on', 0, False)
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("on", state.attributes.get('swing_mode'))
|
||||
assert "on" == state.attributes.get('swing_mode')
|
||||
|
||||
def test_set_target_temperature(self):
|
||||
"""Test setting the target temperature."""
|
||||
assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(21, state.attributes.get('temperature'))
|
||||
assert 21 == state.attributes.get('temperature')
|
||||
common.set_operation_mode(self.hass, 'heat', ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('heat', state.attributes.get('operation_mode'))
|
||||
assert 'heat' == state.attributes.get('operation_mode')
|
||||
self.mock_publish.async_publish.assert_called_once_with(
|
||||
'mode-topic', 'heat', 0, False)
|
||||
self.mock_publish.async_publish.reset_mock()
|
||||
@@ -284,7 +284,7 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
entity_id=ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(47, state.attributes.get('temperature'))
|
||||
assert 47 == state.attributes.get('temperature')
|
||||
self.mock_publish.async_publish.assert_called_once_with(
|
||||
'temperature-topic', 47, 0, False)
|
||||
|
||||
@@ -295,8 +295,8 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
entity_id=ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('cool', state.attributes.get('operation_mode'))
|
||||
self.assertEqual(21, state.attributes.get('temperature'))
|
||||
assert 'cool' == state.attributes.get('operation_mode')
|
||||
assert 21 == state.attributes.get('temperature')
|
||||
self.mock_publish.async_publish.assert_has_calls([
|
||||
unittest.mock.call('mode-topic', 'cool', 0, False),
|
||||
unittest.mock.call('temperature-topic', 21, 0, False)
|
||||
@@ -310,24 +310,24 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
assert setup_component(self.hass, climate.DOMAIN, config)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(None, state.attributes.get('temperature'))
|
||||
assert state.attributes.get('temperature') is None
|
||||
common.set_operation_mode(self.hass, 'heat', ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
common.set_temperature(self.hass, temperature=47,
|
||||
entity_id=ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(None, state.attributes.get('temperature'))
|
||||
assert state.attributes.get('temperature') is None
|
||||
|
||||
fire_mqtt_message(self.hass, 'temperature-state', '1701')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(1701, state.attributes.get('temperature'))
|
||||
assert 1701 == state.attributes.get('temperature')
|
||||
|
||||
fire_mqtt_message(self.hass, 'temperature-state', 'not a number')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(1701, state.attributes.get('temperature'))
|
||||
assert 1701 == state.attributes.get('temperature')
|
||||
|
||||
def test_receive_mqtt_temperature(self):
|
||||
"""Test getting the current temperature via MQTT."""
|
||||
@@ -339,7 +339,7 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
fire_mqtt_message(self.hass, 'current_temperature', '47')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(47, state.attributes.get('current_temperature'))
|
||||
assert 47 == state.attributes.get('current_temperature')
|
||||
|
||||
def test_set_away_mode_pessimistic(self):
|
||||
"""Test setting of the away mode."""
|
||||
@@ -348,27 +348,27 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
assert setup_component(self.hass, climate.DOMAIN, config)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('away_mode'))
|
||||
assert 'off' == state.attributes.get('away_mode')
|
||||
|
||||
common.set_away_mode(self.hass, True, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('away_mode'))
|
||||
assert 'off' == state.attributes.get('away_mode')
|
||||
|
||||
fire_mqtt_message(self.hass, 'away-state', 'ON')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('on', state.attributes.get('away_mode'))
|
||||
assert 'on' == state.attributes.get('away_mode')
|
||||
|
||||
fire_mqtt_message(self.hass, 'away-state', 'OFF')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('away_mode'))
|
||||
assert 'off' == state.attributes.get('away_mode')
|
||||
|
||||
fire_mqtt_message(self.hass, 'away-state', 'nonsense')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('away_mode'))
|
||||
assert 'off' == state.attributes.get('away_mode')
|
||||
|
||||
def test_set_away_mode(self):
|
||||
"""Test setting of the away mode."""
|
||||
@@ -379,21 +379,21 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
assert setup_component(self.hass, climate.DOMAIN, config)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('away_mode'))
|
||||
assert 'off' == state.attributes.get('away_mode')
|
||||
common.set_away_mode(self.hass, True, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
self.mock_publish.async_publish.assert_called_once_with(
|
||||
'away-mode-topic', 'AN', 0, False)
|
||||
self.mock_publish.async_publish.reset_mock()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('on', state.attributes.get('away_mode'))
|
||||
assert 'on' == state.attributes.get('away_mode')
|
||||
|
||||
common.set_away_mode(self.hass, False, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
self.mock_publish.async_publish.assert_called_once_with(
|
||||
'away-mode-topic', 'AUS', 0, False)
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('away_mode'))
|
||||
assert 'off' == state.attributes.get('away_mode')
|
||||
|
||||
def test_set_hold_pessimistic(self):
|
||||
"""Test setting the hold mode in pessimistic mode."""
|
||||
@@ -402,43 +402,43 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
assert setup_component(self.hass, climate.DOMAIN, config)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(None, state.attributes.get('hold_mode'))
|
||||
assert state.attributes.get('hold_mode') is None
|
||||
|
||||
common.set_hold_mode(self.hass, 'on', ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(None, state.attributes.get('hold_mode'))
|
||||
assert state.attributes.get('hold_mode') is None
|
||||
|
||||
fire_mqtt_message(self.hass, 'hold-state', 'on')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('on', state.attributes.get('hold_mode'))
|
||||
assert 'on' == state.attributes.get('hold_mode')
|
||||
|
||||
fire_mqtt_message(self.hass, 'hold-state', 'off')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('hold_mode'))
|
||||
assert 'off' == state.attributes.get('hold_mode')
|
||||
|
||||
def test_set_hold(self):
|
||||
"""Test setting the hold mode."""
|
||||
assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(None, state.attributes.get('hold_mode'))
|
||||
assert state.attributes.get('hold_mode') is None
|
||||
common.set_hold_mode(self.hass, 'on', ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
self.mock_publish.async_publish.assert_called_once_with(
|
||||
'hold-topic', 'on', 0, False)
|
||||
self.mock_publish.async_publish.reset_mock()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('on', state.attributes.get('hold_mode'))
|
||||
assert 'on' == state.attributes.get('hold_mode')
|
||||
|
||||
common.set_hold_mode(self.hass, 'off', ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
self.mock_publish.async_publish.assert_called_once_with(
|
||||
'hold-topic', 'off', 0, False)
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('hold_mode'))
|
||||
assert 'off' == state.attributes.get('hold_mode')
|
||||
|
||||
def test_set_aux_pessimistic(self):
|
||||
"""Test setting of the aux heating in pessimistic mode."""
|
||||
@@ -447,48 +447,48 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
assert setup_component(self.hass, climate.DOMAIN, config)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('aux_heat'))
|
||||
assert 'off' == state.attributes.get('aux_heat')
|
||||
|
||||
common.set_aux_heat(self.hass, True, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('aux_heat'))
|
||||
assert 'off' == state.attributes.get('aux_heat')
|
||||
|
||||
fire_mqtt_message(self.hass, 'aux-state', 'ON')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('on', state.attributes.get('aux_heat'))
|
||||
assert 'on' == state.attributes.get('aux_heat')
|
||||
|
||||
fire_mqtt_message(self.hass, 'aux-state', 'OFF')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('aux_heat'))
|
||||
assert 'off' == state.attributes.get('aux_heat')
|
||||
|
||||
fire_mqtt_message(self.hass, 'aux-state', 'nonsense')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('aux_heat'))
|
||||
assert 'off' == state.attributes.get('aux_heat')
|
||||
|
||||
def test_set_aux(self):
|
||||
"""Test setting of the aux heating."""
|
||||
assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('aux_heat'))
|
||||
assert 'off' == state.attributes.get('aux_heat')
|
||||
common.set_aux_heat(self.hass, True, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
self.mock_publish.async_publish.assert_called_once_with(
|
||||
'aux-topic', 'ON', 0, False)
|
||||
self.mock_publish.async_publish.reset_mock()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('on', state.attributes.get('aux_heat'))
|
||||
assert 'on' == state.attributes.get('aux_heat')
|
||||
|
||||
common.set_aux_heat(self.hass, False, ENTITY_CLIMATE)
|
||||
self.hass.block_till_done()
|
||||
self.mock_publish.async_publish.assert_called_once_with(
|
||||
'aux-topic', 'OFF', 0, False)
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('aux_heat'))
|
||||
assert 'off' == state.attributes.get('aux_heat')
|
||||
|
||||
def test_custom_availability_payload(self):
|
||||
"""Test availability by custom payload with defined topic."""
|
||||
@@ -500,19 +500,19 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
assert setup_component(self.hass, climate.DOMAIN, config)
|
||||
|
||||
state = self.hass.states.get('climate.test')
|
||||
self.assertEqual(STATE_UNAVAILABLE, state.state)
|
||||
assert STATE_UNAVAILABLE == state.state
|
||||
|
||||
fire_mqtt_message(self.hass, 'availability-topic', 'good')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('climate.test')
|
||||
self.assertNotEqual(STATE_UNAVAILABLE, state.state)
|
||||
assert STATE_UNAVAILABLE != state.state
|
||||
|
||||
fire_mqtt_message(self.hass, 'availability-topic', 'nogood')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('climate.test')
|
||||
self.assertEqual(STATE_UNAVAILABLE, state.state)
|
||||
assert STATE_UNAVAILABLE == state.state
|
||||
|
||||
def test_set_with_templates(self):
|
||||
"""Test setting of new fan mode in pessimistic mode."""
|
||||
@@ -539,32 +539,32 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
|
||||
# Operation Mode
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(None, state.attributes.get('operation_mode'))
|
||||
assert state.attributes.get('operation_mode') is None
|
||||
fire_mqtt_message(self.hass, 'mode-state', '"cool"')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("cool", state.attributes.get('operation_mode'))
|
||||
assert "cool" == state.attributes.get('operation_mode')
|
||||
|
||||
# Fan Mode
|
||||
self.assertEqual(None, state.attributes.get('fan_mode'))
|
||||
assert state.attributes.get('fan_mode') is None
|
||||
fire_mqtt_message(self.hass, 'fan-state', '"high"')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('high', state.attributes.get('fan_mode'))
|
||||
assert 'high' == state.attributes.get('fan_mode')
|
||||
|
||||
# Swing Mode
|
||||
self.assertEqual(None, state.attributes.get('swing_mode'))
|
||||
assert state.attributes.get('swing_mode') is None
|
||||
fire_mqtt_message(self.hass, 'swing-state', '"on"')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual("on", state.attributes.get('swing_mode'))
|
||||
assert "on" == state.attributes.get('swing_mode')
|
||||
|
||||
# Temperature - with valid value
|
||||
self.assertEqual(None, state.attributes.get('temperature'))
|
||||
assert state.attributes.get('temperature') is None
|
||||
fire_mqtt_message(self.hass, 'temperature-state', '"1031"')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(1031, state.attributes.get('temperature'))
|
||||
assert 1031 == state.attributes.get('temperature')
|
||||
|
||||
# Temperature - with invalid value
|
||||
with self.assertLogs(level='ERROR') as log:
|
||||
@@ -572,60 +572,58 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
# make sure, the invalid value gets logged...
|
||||
self.assertEqual(len(log.output), 1)
|
||||
self.assertEqual(len(log.records), 1)
|
||||
self.assertIn(
|
||||
"Could not parse temperature from -INVALID-",
|
||||
assert len(log.output) == 1
|
||||
assert len(log.records) == 1
|
||||
assert "Could not parse temperature from -INVALID-" in \
|
||||
log.output[0]
|
||||
)
|
||||
# ... but the actual value stays unchanged.
|
||||
self.assertEqual(1031, state.attributes.get('temperature'))
|
||||
assert 1031 == state.attributes.get('temperature')
|
||||
|
||||
# Away Mode
|
||||
self.assertEqual('off', state.attributes.get('away_mode'))
|
||||
assert 'off' == state.attributes.get('away_mode')
|
||||
fire_mqtt_message(self.hass, 'away-state', '"ON"')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('on', state.attributes.get('away_mode'))
|
||||
assert 'on' == state.attributes.get('away_mode')
|
||||
|
||||
# Away Mode with JSON values
|
||||
fire_mqtt_message(self.hass, 'away-state', 'false')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('away_mode'))
|
||||
assert 'off' == state.attributes.get('away_mode')
|
||||
|
||||
fire_mqtt_message(self.hass, 'away-state', 'true')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('on', state.attributes.get('away_mode'))
|
||||
assert 'on' == state.attributes.get('away_mode')
|
||||
|
||||
# Hold Mode
|
||||
self.assertEqual(None, state.attributes.get('hold_mode'))
|
||||
assert state.attributes.get('hold_mode') is None
|
||||
fire_mqtt_message(self.hass, 'hold-state', """
|
||||
{ "attribute": "somemode" }
|
||||
""")
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('somemode', state.attributes.get('hold_mode'))
|
||||
assert 'somemode' == state.attributes.get('hold_mode')
|
||||
|
||||
# Aux mode
|
||||
self.assertEqual('off', state.attributes.get('aux_heat'))
|
||||
assert 'off' == state.attributes.get('aux_heat')
|
||||
fire_mqtt_message(self.hass, 'aux-state', 'switchmeon')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('on', state.attributes.get('aux_heat'))
|
||||
assert 'on' == state.attributes.get('aux_heat')
|
||||
|
||||
# anything other than 'switchmeon' should turn Aux mode off
|
||||
fire_mqtt_message(self.hass, 'aux-state', 'somerandomstring')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual('off', state.attributes.get('aux_heat'))
|
||||
assert 'off' == state.attributes.get('aux_heat')
|
||||
|
||||
# Current temperature
|
||||
fire_mqtt_message(self.hass, 'current-temperature', '"74656"')
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(74656, state.attributes.get('current_temperature'))
|
||||
assert 74656 == state.attributes.get('current_temperature')
|
||||
|
||||
def test_min_temp_custom(self):
|
||||
"""Test a custom min temp."""
|
||||
@@ -637,8 +635,8 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
min_temp = state.attributes.get('min_temp')
|
||||
|
||||
self.assertIsInstance(min_temp, float)
|
||||
self.assertEqual(26, state.attributes.get('min_temp'))
|
||||
assert isinstance(min_temp, float)
|
||||
assert 26 == state.attributes.get('min_temp')
|
||||
|
||||
def test_max_temp_custom(self):
|
||||
"""Test a custom max temp."""
|
||||
@@ -650,8 +648,8 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
max_temp = state.attributes.get('max_temp')
|
||||
|
||||
self.assertIsInstance(max_temp, float)
|
||||
self.assertEqual(60, max_temp)
|
||||
assert isinstance(max_temp, float)
|
||||
assert 60 == max_temp
|
||||
|
||||
def test_temp_step_custom(self):
|
||||
"""Test a custom temp step."""
|
||||
@@ -663,8 +661,8 @@ class TestMQTTClimate(unittest.TestCase):
|
||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
temp_step = state.attributes.get('target_temp_step')
|
||||
|
||||
self.assertIsInstance(temp_step, float)
|
||||
self.assertEqual(0.01, temp_step)
|
||||
assert isinstance(temp_step, float)
|
||||
assert 0.01 == temp_step
|
||||
|
||||
|
||||
async def test_discovery_removal_climate(hass, mqtt_mock, caplog):
|
||||
|
||||
@@ -104,111 +104,105 @@ class TestNuHeat(unittest.TestCase):
|
||||
|
||||
def test_name(self):
|
||||
"""Test name property."""
|
||||
self.assertEqual(self.thermostat.name, "Master bathroom")
|
||||
assert self.thermostat.name == "Master bathroom"
|
||||
|
||||
def test_icon(self):
|
||||
"""Test name property."""
|
||||
self.assertEqual(self.thermostat.icon, "mdi:thermometer")
|
||||
assert self.thermostat.icon == "mdi:thermometer"
|
||||
|
||||
def test_supported_features(self):
|
||||
"""Test name property."""
|
||||
features = (SUPPORT_TARGET_TEMPERATURE | SUPPORT_HOLD_MODE |
|
||||
SUPPORT_OPERATION_MODE)
|
||||
self.assertEqual(self.thermostat.supported_features, features)
|
||||
assert self.thermostat.supported_features == features
|
||||
|
||||
def test_temperature_unit(self):
|
||||
"""Test temperature unit."""
|
||||
self.assertEqual(self.thermostat.temperature_unit, TEMP_FAHRENHEIT)
|
||||
assert self.thermostat.temperature_unit == TEMP_FAHRENHEIT
|
||||
self.thermostat._temperature_unit = "C"
|
||||
self.assertEqual(self.thermostat.temperature_unit, TEMP_CELSIUS)
|
||||
assert self.thermostat.temperature_unit == TEMP_CELSIUS
|
||||
|
||||
def test_current_temperature(self):
|
||||
"""Test current temperature."""
|
||||
self.assertEqual(self.thermostat.current_temperature, 72)
|
||||
assert self.thermostat.current_temperature == 72
|
||||
self.thermostat._temperature_unit = "C"
|
||||
self.assertEqual(self.thermostat.current_temperature, 22)
|
||||
assert self.thermostat.current_temperature == 22
|
||||
|
||||
def test_current_operation(self):
|
||||
"""Test current operation."""
|
||||
self.assertEqual(self.thermostat.current_operation, STATE_HEAT)
|
||||
assert self.thermostat.current_operation == STATE_HEAT
|
||||
self.thermostat._thermostat.heating = False
|
||||
self.assertEqual(self.thermostat.current_operation, STATE_IDLE)
|
||||
assert self.thermostat.current_operation == STATE_IDLE
|
||||
|
||||
def test_min_temp(self):
|
||||
"""Test min temp."""
|
||||
self.assertEqual(self.thermostat.min_temp, 41)
|
||||
assert self.thermostat.min_temp == 41
|
||||
self.thermostat._temperature_unit = "C"
|
||||
self.assertEqual(self.thermostat.min_temp, 5)
|
||||
assert self.thermostat.min_temp == 5
|
||||
|
||||
def test_max_temp(self):
|
||||
"""Test max temp."""
|
||||
self.assertEqual(self.thermostat.max_temp, 157)
|
||||
assert self.thermostat.max_temp == 157
|
||||
self.thermostat._temperature_unit = "C"
|
||||
self.assertEqual(self.thermostat.max_temp, 69)
|
||||
assert self.thermostat.max_temp == 69
|
||||
|
||||
def test_target_temperature(self):
|
||||
"""Test target temperature."""
|
||||
self.assertEqual(self.thermostat.target_temperature, 72)
|
||||
assert self.thermostat.target_temperature == 72
|
||||
self.thermostat._temperature_unit = "C"
|
||||
self.assertEqual(self.thermostat.target_temperature, 22)
|
||||
assert self.thermostat.target_temperature == 22
|
||||
|
||||
def test_current_hold_mode(self):
|
||||
"""Test current hold mode."""
|
||||
self.thermostat._thermostat.schedule_mode = SCHEDULE_RUN
|
||||
self.assertEqual(self.thermostat.current_hold_mode, nuheat.MODE_AUTO)
|
||||
assert self.thermostat.current_hold_mode == nuheat.MODE_AUTO
|
||||
|
||||
self.thermostat._thermostat.schedule_mode = SCHEDULE_HOLD
|
||||
self.assertEqual(
|
||||
self.thermostat.current_hold_mode, nuheat.MODE_HOLD_TEMPERATURE)
|
||||
assert self.thermostat.current_hold_mode == \
|
||||
nuheat.MODE_HOLD_TEMPERATURE
|
||||
|
||||
self.thermostat._thermostat.schedule_mode = SCHEDULE_TEMPORARY_HOLD
|
||||
self.assertEqual(
|
||||
self.thermostat.current_hold_mode, nuheat.MODE_TEMPORARY_HOLD)
|
||||
assert self.thermostat.current_hold_mode == nuheat.MODE_TEMPORARY_HOLD
|
||||
|
||||
self.thermostat._thermostat.schedule_mode = None
|
||||
self.assertEqual(
|
||||
self.thermostat.current_hold_mode, nuheat.MODE_AUTO)
|
||||
assert self.thermostat.current_hold_mode == nuheat.MODE_AUTO
|
||||
|
||||
def test_operation_list(self):
|
||||
"""Test the operation list."""
|
||||
self.assertEqual(
|
||||
self.thermostat.operation_list,
|
||||
assert self.thermostat.operation_list == \
|
||||
[STATE_HEAT, STATE_IDLE]
|
||||
)
|
||||
|
||||
def test_resume_program(self):
|
||||
"""Test resume schedule."""
|
||||
self.thermostat.resume_program()
|
||||
self.thermostat._thermostat.resume_schedule.assert_called_once_with()
|
||||
self.assertTrue(self.thermostat._force_update)
|
||||
assert self.thermostat._force_update
|
||||
|
||||
def test_set_hold_mode(self):
|
||||
"""Test set hold mode."""
|
||||
self.thermostat.set_hold_mode("temperature")
|
||||
self.assertEqual(
|
||||
self.thermostat._thermostat.schedule_mode, SCHEDULE_HOLD)
|
||||
self.assertTrue(self.thermostat._force_update)
|
||||
assert self.thermostat._thermostat.schedule_mode == SCHEDULE_HOLD
|
||||
assert self.thermostat._force_update
|
||||
|
||||
self.thermostat.set_hold_mode("temporary_temperature")
|
||||
self.assertEqual(
|
||||
self.thermostat._thermostat.schedule_mode, SCHEDULE_TEMPORARY_HOLD)
|
||||
self.assertTrue(self.thermostat._force_update)
|
||||
assert self.thermostat._thermostat.schedule_mode == \
|
||||
SCHEDULE_TEMPORARY_HOLD
|
||||
assert self.thermostat._force_update
|
||||
|
||||
self.thermostat.set_hold_mode("auto")
|
||||
self.assertEqual(
|
||||
self.thermostat._thermostat.schedule_mode, SCHEDULE_RUN)
|
||||
self.assertTrue(self.thermostat._force_update)
|
||||
assert self.thermostat._thermostat.schedule_mode == SCHEDULE_RUN
|
||||
assert self.thermostat._force_update
|
||||
|
||||
def test_set_temperature(self):
|
||||
"""Test set temperature."""
|
||||
self.thermostat.set_temperature(temperature=85)
|
||||
self.assertEqual(self.thermostat._thermostat.target_fahrenheit, 85)
|
||||
self.assertTrue(self.thermostat._force_update)
|
||||
assert self.thermostat._thermostat.target_fahrenheit == 85
|
||||
assert self.thermostat._force_update
|
||||
|
||||
self.thermostat._temperature_unit = "C"
|
||||
self.thermostat.set_temperature(temperature=23)
|
||||
self.assertEqual(self.thermostat._thermostat.target_celsius, 23)
|
||||
self.assertTrue(self.thermostat._force_update)
|
||||
assert self.thermostat._thermostat.target_celsius == 23
|
||||
assert self.thermostat._force_update
|
||||
|
||||
@patch.object(nuheat.NuHeatThermostat, "_throttled_update")
|
||||
def test_update_without_throttle(self, throttled_update):
|
||||
@@ -216,7 +210,7 @@ class TestNuHeat(unittest.TestCase):
|
||||
self.thermostat._force_update = True
|
||||
self.thermostat.update()
|
||||
throttled_update.assert_called_once_with(no_throttle=True)
|
||||
self.assertFalse(self.thermostat._force_update)
|
||||
assert not self.thermostat._force_update
|
||||
|
||||
@patch.object(nuheat.NuHeatThermostat, "_throttled_update")
|
||||
def test_update_with_throttle(self, throttled_update):
|
||||
@@ -224,7 +218,7 @@ class TestNuHeat(unittest.TestCase):
|
||||
self.thermostat._force_update = False
|
||||
self.thermostat.update()
|
||||
throttled_update.assert_called_once_with()
|
||||
self.assertFalse(self.thermostat._force_update)
|
||||
assert not self.thermostat._force_update
|
||||
|
||||
def test_throttled_update(self):
|
||||
"""Test update with throttle."""
|
||||
|
||||
Reference in new issue
Block a user