mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-02-15 15:29:58 +00:00
Refactor devices into subpackages and deprecate old names (#716)
* Refactor devices into subpackages and deprecate old names * Tweak and add tests * Fix linting * Remove duplicate implementations affecting project coverage * Update post review * Add device base class attributes and rename subclasses * Rename Module to BaseModule * Remove has_emeter_history * Fix missing _time in init * Update post review * Fix test_readmeexamples * Fix erroneously duped files * Clean up iot and smart imports * Update post latest review * Tweak Device docstring
This commit is contained in:
@@ -11,7 +11,8 @@ from voluptuous import (
|
||||
)
|
||||
|
||||
from kasa import EmeterStatus, SmartDeviceException
|
||||
from kasa.modules.emeter import Emeter
|
||||
from kasa.iot import IotDevice
|
||||
from kasa.iot.modules.emeter import Emeter
|
||||
|
||||
from .conftest import has_emeter, has_emeter_iot, no_emeter
|
||||
|
||||
@@ -39,12 +40,15 @@ async def test_no_emeter(dev):
|
||||
|
||||
with pytest.raises(SmartDeviceException):
|
||||
await dev.get_emeter_realtime()
|
||||
with pytest.raises(SmartDeviceException):
|
||||
await dev.get_emeter_daily()
|
||||
with pytest.raises(SmartDeviceException):
|
||||
await dev.get_emeter_monthly()
|
||||
with pytest.raises(SmartDeviceException):
|
||||
await dev.erase_emeter_stats()
|
||||
# Only iot devices support the historical stats so other
|
||||
# devices will not implement the methods below
|
||||
if isinstance(dev, IotDevice):
|
||||
with pytest.raises(SmartDeviceException):
|
||||
await dev.get_emeter_daily()
|
||||
with pytest.raises(SmartDeviceException):
|
||||
await dev.get_emeter_monthly()
|
||||
with pytest.raises(SmartDeviceException):
|
||||
await dev.erase_emeter_stats()
|
||||
|
||||
|
||||
@has_emeter
|
||||
@@ -121,7 +125,7 @@ async def test_erase_emeter_stats(dev):
|
||||
await dev.erase_emeter()
|
||||
|
||||
|
||||
@has_emeter
|
||||
@has_emeter_iot
|
||||
async def test_current_consumption(dev):
|
||||
if dev.has_emeter:
|
||||
x = await dev.current_consumption()
|
||||
|
||||
Reference in New Issue
Block a user