mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-11-15 22:58:42 +00:00
Improve testing harness to allow tests on real devices (#197)
* test_cli: provide return values to patched objects to avoid warning about non-awaited calls
* test_cli: restore alias after testing
* smartstrip: remove internal update() calls for turn_{on,off}, set_led
* Make sure power is always a float
* Fix discovery tests
* Make tests runnable on real devices
* Add a note about running tests on a real device
* test_strip: run update against the parent device
This commit is contained in:
@@ -13,6 +13,7 @@ async def test_state_info(dev):
|
||||
assert isinstance(dev.state_information, dict)
|
||||
|
||||
|
||||
@pytest.mark.requires_dummy
|
||||
async def test_invalid_connection(dev):
|
||||
with patch.object(FakeTransportProtocol, "query", side_effect=SmartDeviceException):
|
||||
with pytest.raises(SmartDeviceException):
|
||||
@@ -49,18 +50,22 @@ async def test_state(dev, turn_on):
|
||||
orig_state = dev.is_on
|
||||
if orig_state:
|
||||
await dev.turn_off()
|
||||
await dev.update()
|
||||
assert not dev.is_on
|
||||
assert dev.is_off
|
||||
|
||||
await dev.turn_on()
|
||||
await dev.update()
|
||||
assert dev.is_on
|
||||
assert not dev.is_off
|
||||
else:
|
||||
await dev.turn_on()
|
||||
await dev.update()
|
||||
assert dev.is_on
|
||||
assert not dev.is_off
|
||||
|
||||
await dev.turn_off()
|
||||
await dev.update()
|
||||
assert not dev.is_on
|
||||
assert dev.is_off
|
||||
|
||||
@@ -71,9 +76,11 @@ async def test_alias(dev):
|
||||
|
||||
assert isinstance(original, str)
|
||||
await dev.set_alias(test_alias)
|
||||
await dev.update()
|
||||
assert dev.alias == test_alias
|
||||
|
||||
await dev.set_alias(original)
|
||||
await dev.update()
|
||||
assert dev.alias == original
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user