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
@@ -130,14 +130,14 @@ class DysonTest(unittest.TestCase):
|
||||
}
|
||||
})
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(len(self.hass.data[dyson.DYSON_DEVICES]), 1)
|
||||
assert len(self.hass.data[dyson.DYSON_DEVICES]) == 1
|
||||
assert mocked_devices.return_value[0].add_message_listener.called
|
||||
|
||||
def test_dyson_set_speed(self):
|
||||
"""Test set fan speed."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertFalse(component.should_poll)
|
||||
assert not component.should_poll
|
||||
component.set_speed("1")
|
||||
set_config = device.set_configuration
|
||||
set_config.assert_called_with(fan_mode=FanMode.FAN,
|
||||
@@ -151,7 +151,7 @@ class DysonTest(unittest.TestCase):
|
||||
"""Test turn on fan."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertFalse(component.should_poll)
|
||||
assert not component.should_poll
|
||||
component.turn_on()
|
||||
set_config = device.set_configuration
|
||||
set_config.assert_called_with(fan_mode=FanMode.FAN)
|
||||
@@ -160,7 +160,7 @@ class DysonTest(unittest.TestCase):
|
||||
"""Test turn on fan with night mode."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertFalse(component.should_poll)
|
||||
assert not component.should_poll
|
||||
component.night_mode(True)
|
||||
set_config = device.set_configuration
|
||||
set_config.assert_called_with(night_mode=NightMode.NIGHT_MODE_ON)
|
||||
@@ -173,17 +173,17 @@ class DysonTest(unittest.TestCase):
|
||||
"""Test night mode."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertFalse(component.is_night_mode)
|
||||
assert not component.is_night_mode
|
||||
|
||||
device = _get_device_off()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertTrue(component.is_night_mode)
|
||||
assert component.is_night_mode
|
||||
|
||||
def test_dyson_turn_auto_mode(self):
|
||||
"""Test turn on/off fan with auto mode."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertFalse(component.should_poll)
|
||||
assert not component.should_poll
|
||||
component.auto_mode(True)
|
||||
set_config = device.set_configuration
|
||||
set_config.assert_called_with(fan_mode=FanMode.AUTO)
|
||||
@@ -196,17 +196,17 @@ class DysonTest(unittest.TestCase):
|
||||
"""Test auto mode."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertFalse(component.is_auto_mode)
|
||||
assert not component.is_auto_mode
|
||||
|
||||
device = _get_device_auto()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertTrue(component.is_auto_mode)
|
||||
assert component.is_auto_mode
|
||||
|
||||
def test_dyson_turn_on_speed(self):
|
||||
"""Test turn on fan with specified speed."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertFalse(component.should_poll)
|
||||
assert not component.should_poll
|
||||
component.turn_on("1")
|
||||
set_config = device.set_configuration
|
||||
set_config.assert_called_with(fan_mode=FanMode.FAN,
|
||||
@@ -220,7 +220,7 @@ class DysonTest(unittest.TestCase):
|
||||
"""Test turn off fan."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertFalse(component.should_poll)
|
||||
assert not component.should_poll
|
||||
component.turn_off()
|
||||
set_config = device.set_configuration
|
||||
set_config.assert_called_with(fan_mode=FanMode.OFF)
|
||||
@@ -245,65 +245,65 @@ class DysonTest(unittest.TestCase):
|
||||
"""Test get oscillation value on."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertTrue(component.oscillating)
|
||||
assert component.oscillating
|
||||
|
||||
def test_dyson_oscillate_value_off(self):
|
||||
"""Test get oscillation value off."""
|
||||
device = _get_device_off()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertFalse(component.oscillating)
|
||||
assert not component.oscillating
|
||||
|
||||
def test_dyson_on(self):
|
||||
"""Test device is on."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertTrue(component.is_on)
|
||||
assert component.is_on
|
||||
|
||||
def test_dyson_off(self):
|
||||
"""Test device is off."""
|
||||
device = _get_device_off()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertFalse(component.is_on)
|
||||
assert not component.is_on
|
||||
|
||||
device = _get_device_with_no_state()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertFalse(component.is_on)
|
||||
assert not component.is_on
|
||||
|
||||
def test_dyson_get_speed(self):
|
||||
"""Test get device speed."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertEqual(component.speed, 1)
|
||||
assert component.speed == 1
|
||||
|
||||
device = _get_device_off()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertEqual(component.speed, 4)
|
||||
assert component.speed == 4
|
||||
|
||||
device = _get_device_with_no_state()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertIsNone(component.speed)
|
||||
assert component.speed is None
|
||||
|
||||
device = _get_device_auto()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertEqual(component.speed, "AUTO")
|
||||
assert component.speed == "AUTO"
|
||||
|
||||
def test_dyson_get_direction(self):
|
||||
"""Test get device direction."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertIsNone(component.current_direction)
|
||||
assert component.current_direction is None
|
||||
|
||||
def test_dyson_get_speed_list(self):
|
||||
"""Test get speeds list."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertEqual(len(component.speed_list), 11)
|
||||
assert len(component.speed_list) == 11
|
||||
|
||||
def test_dyson_supported_features(self):
|
||||
"""Test supported features."""
|
||||
device = _get_device_on()
|
||||
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
|
||||
self.assertEqual(component.supported_features, 3)
|
||||
assert component.supported_features == 3
|
||||
|
||||
def test_on_message(self):
|
||||
"""Test when message is received."""
|
||||
|
||||
Reference in new issue
Block a user