diff --git a/devtools/dump_devinfo.py b/devtools/dump_devinfo.py index 83df9dcd..541d128d 100644 --- a/devtools/dump_devinfo.py +++ b/devtools/dump_devinfo.py @@ -44,8 +44,8 @@ from kasa.experimental.smartcameraprotocol import ( SmartCameraProtocol, _ChildCameraProtocolWrapper, ) +from kasa.protocols.smartprotocol import SmartProtocol, _ChildProtocolWrapper from kasa.smart import SmartChildDevice -from kasa.smartprotocol import SmartProtocol, _ChildProtocolWrapper Call = namedtuple("Call", "module method") FixtureResult = namedtuple("FixtureResult", "filename, folder, data") diff --git a/devtools/parse_pcap_klap.py b/devtools/parse_pcap_klap.py index 9af59023..0ddbed7f 100755 --- a/devtools/parse_pcap_klap.py +++ b/devtools/parse_pcap_klap.py @@ -18,14 +18,13 @@ import asyncclick as click import pyshark from cryptography.hazmat.primitives import padding -from kasa.credentials import Credentials +from kasa.credentials import DEFAULT_CREDENTIALS, Credentials, get_default_credentials from kasa.deviceconfig import ( DeviceConfig, DeviceConnectionParameters, DeviceEncryptionType, DeviceFamily, ) -from kasa.protocol import DEFAULT_CREDENTIALS, get_default_credentials from kasa.transports.klaptransport import KlapEncryptionSession, KlapTransportV2 diff --git a/docs/source/reference.md b/docs/source/reference.md index b8ebee9f..f4771ac5 100644 --- a/docs/source/reference.md +++ b/docs/source/reference.md @@ -86,21 +86,21 @@ ## Protocols and transports ```{eval-rst} -.. autoclass:: kasa.protocol.BaseProtocol +.. autoclass:: kasa.protocols.BaseProtocol :members: :inherited-members: :undoc-members: ``` ```{eval-rst} -.. autoclass:: kasa.iotprotocol.IotProtocol +.. autoclass:: kasa.protocols.IotProtocol :members: :inherited-members: :undoc-members: ``` ```{eval-rst} -.. autoclass:: kasa.smartprotocol.SmartProtocol +.. autoclass:: kasa.protocols.SmartProtocol :members: :inherited-members: :undoc-members: diff --git a/docs/source/topics.md b/docs/source/topics.md index 0ff66ede..0dcc60d1 100644 --- a/docs/source/topics.md +++ b/docs/source/topics.md @@ -116,15 +116,15 @@ In order to support these different configurations the library migrated from a s to support pluggable transports and protocols. The classes providing this functionality are: -- {class}`BaseProtocol ` -- {class}`IotProtocol ` -- {class}`SmartProtocol ` +- {class}`BaseProtocol ` +- {class}`IotProtocol ` +- {class}`SmartProtocol ` -- {class}`BaseTransport ` -- {class}`XorTransport ` -- {class}`AesTransport ` -- {class}`KlapTransport ` -- {class}`KlapTransportV2 ` +- {class}`BaseTransport ` +- {class}`XorTransport ` +- {class}`AesTransport ` +- {class}`KlapTransport ` +- {class}`KlapTransportV2 ` (topics-errors-and-exceptions)= ## Errors and Exceptions @@ -166,42 +166,42 @@ API documentation for modules and features API documentation for protocols and transports ********************************************** -.. autoclass:: kasa.protocol.BaseProtocol +.. autoclass:: kasa.protocols.BaseProtocol :members: :inherited-members: :undoc-members: -.. autoclass:: kasa.iotprotocol.IotProtocol +.. autoclass:: kasa.protocols.IotProtocol :members: :inherited-members: :undoc-members: -.. autoclass:: kasa.smartprotocol.SmartProtocol +.. autoclass:: kasa.protocols.SmartProtocol :members: :inherited-members: :undoc-members: -.. autoclass:: kasa.protocol.BaseTransport +.. autoclass:: kasa.transports.BaseTransport :members: :inherited-members: :undoc-members: -.. autoclass:: kasa.xortransport.XorTransport +.. autoclass:: kasa.transports.XorTransport :members: :inherited-members: :undoc-members: -.. autoclass:: kasa.klaptransport.KlapTransport +.. autoclass:: kasa.transports.KlapTransport :members: :inherited-members: :undoc-members: -.. autoclass:: kasa.klaptransport.KlapTransportV2 +.. autoclass:: kasa.transports.KlapTransportV2 :members: :inherited-members: :undoc-members: -.. autoclass:: kasa.aestransport.AesTransport +.. autoclass:: kasa.transports.AesTransport :members: :inherited-members: :undoc-members: diff --git a/kasa/__init__.py b/kasa/__init__.py index 49e77966..7fb80ab5 100755 --- a/kasa/__init__.py +++ b/kasa/__init__.py @@ -36,13 +36,9 @@ from kasa.exceptions import ( ) from kasa.feature import Feature from kasa.interfaces.light import HSV, ColorTempRange, Light, LightState -from kasa.iotprotocol import ( - IotProtocol, - _deprecated_TPLinkSmartHomeProtocol, # noqa: F401 -) from kasa.module import Module -from kasa.protocol import BaseProtocol -from kasa.smartprotocol import SmartProtocol +from kasa.protocols import BaseProtocol, IotProtocol, SmartProtocol +from kasa.protocols.iotprotocol import _deprecated_TPLinkSmartHomeProtocol # noqa: F401 from kasa.transports import BaseTransport __version__ = version("python-kasa") diff --git a/kasa/credentials.py b/kasa/credentials.py index 3cc0b016..2d669999 100644 --- a/kasa/credentials.py +++ b/kasa/credentials.py @@ -1,5 +1,8 @@ """Credentials class for username / passwords.""" +from __future__ import annotations + +import base64 from dataclasses import dataclass, field @@ -11,3 +14,17 @@ class Credentials: username: str = field(default="", repr=False) #: Password of the cloud account password: str = field(default="", repr=False) + + +def get_default_credentials(tuple: tuple[str, str]) -> Credentials: + """Return decoded default credentials.""" + un = base64.b64decode(tuple[0].encode()).decode() + pw = base64.b64decode(tuple[1].encode()).decode() + return Credentials(un, pw) + + +DEFAULT_CREDENTIALS = { + "KASA": ("a2FzYUB0cC1saW5rLm5ldA==", "a2FzYVNldHVw"), + "TAPO": ("dGVzdEB0cC1saW5rLm5ldA==", "dGVzdA=="), + "TAPOCAMERA": ("YWRtaW4=", "YWRtaW4="), +} diff --git a/kasa/device.py b/kasa/device.py index 80139b68..95826ad5 100644 --- a/kasa/device.py +++ b/kasa/device.py @@ -125,9 +125,8 @@ from .deviceconfig import ( ) from .exceptions import KasaException from .feature import Feature -from .iotprotocol import IotProtocol from .module import Module -from .protocol import BaseProtocol +from .protocols import BaseProtocol, IotProtocol from .transports import XorTransport if TYPE_CHECKING: diff --git a/kasa/device_factory.py b/kasa/device_factory.py index 9cdef53e..887f4b68 100755 --- a/kasa/device_factory.py +++ b/kasa/device_factory.py @@ -22,12 +22,12 @@ from .iot import ( IotStrip, IotWallSwitch, ) -from .iotprotocol import IotProtocol -from .protocol import ( +from .protocols import ( BaseProtocol, + IotProtocol, + SmartProtocol, ) from .smart import SmartDevice -from .smartprotocol import SmartProtocol from .transports import ( AesTransport, BaseTransport, diff --git a/kasa/discover.py b/kasa/discover.py index d1240aa8..99adf504 100755 --- a/kasa/discover.py +++ b/kasa/discover.py @@ -131,11 +131,11 @@ from kasa.exceptions import ( ) from kasa.experimental import Experimental from kasa.iot.iotdevice import IotDevice -from kasa.iotprotocol import REDACTORS as IOT_REDACTORS from kasa.json import DataClassJSONMixin from kasa.json import dumps as json_dumps from kasa.json import loads as json_loads -from kasa.protocol import mask_mac, redact_data +from kasa.protocols.iotprotocol import REDACTORS as IOT_REDACTORS +from kasa.protocols.protocol import mask_mac, redact_data from kasa.transports.aestransport import AesEncyptionSession, KeyPair from kasa.transports.xortransport import XorEncryption diff --git a/kasa/experimental/smartcameraprotocol.py b/kasa/experimental/smartcameraprotocol.py index 38530b16..4b9489ae 100644 --- a/kasa/experimental/smartcameraprotocol.py +++ b/kasa/experimental/smartcameraprotocol.py @@ -14,7 +14,7 @@ from ..exceptions import ( _RetryableError, ) from ..json import dumps as json_dumps -from ..smartprotocol import SmartProtocol +from ..protocols import SmartProtocol from .sslaestransport import ( SMART_AUTHENTICATION_ERRORS, SMART_RETRYABLE_ERRORS, diff --git a/kasa/experimental/sslaestransport.py b/kasa/experimental/sslaestransport.py index 6b5144b1..3dff225a 100644 --- a/kasa/experimental/sslaestransport.py +++ b/kasa/experimental/sslaestransport.py @@ -13,7 +13,7 @@ from typing import TYPE_CHECKING, Any, Dict, cast from yarl import URL -from ..credentials import Credentials +from ..credentials import DEFAULT_CREDENTIALS, Credentials, get_default_credentials from ..deviceconfig import DeviceConfig from ..exceptions import ( SMART_AUTHENTICATION_ERRORS, @@ -27,7 +27,6 @@ from ..exceptions import ( from ..httpclient import HttpClient from ..json import dumps as json_dumps from ..json import loads as json_loads -from ..protocol import DEFAULT_CREDENTIALS, get_default_credentials from ..transports import AesEncyptionSession, BaseTransport _LOGGER = logging.getLogger(__name__) diff --git a/kasa/iot/iotbulb.py b/kasa/iot/iotbulb.py index 481a9da8..423e6f38 100644 --- a/kasa/iot/iotbulb.py +++ b/kasa/iot/iotbulb.py @@ -13,7 +13,7 @@ from ..device_type import DeviceType from ..deviceconfig import DeviceConfig from ..interfaces.light import HSV, ColorTempRange from ..module import Module -from ..protocol import BaseProtocol +from ..protocols import BaseProtocol from .iotdevice import IotDevice, KasaException, requires_update from .modules import ( Antitheft, diff --git a/kasa/iot/iotdevice.py b/kasa/iot/iotdevice.py index 20284c1d..1fd8ba39 100755 --- a/kasa/iot/iotdevice.py +++ b/kasa/iot/iotdevice.py @@ -28,7 +28,7 @@ from ..exceptions import KasaException from ..feature import Feature from ..module import Module from ..modulemapping import ModuleMapping, ModuleName -from ..protocol import BaseProtocol +from ..protocols import BaseProtocol from .iotmodule import IotModule, merge from .modules import Emeter diff --git a/kasa/iot/iotdimmer.py b/kasa/iot/iotdimmer.py index 2cd8de44..0c9eb3ea 100644 --- a/kasa/iot/iotdimmer.py +++ b/kasa/iot/iotdimmer.py @@ -8,7 +8,7 @@ from typing import Any from ..device_type import DeviceType from ..deviceconfig import DeviceConfig from ..module import Module -from ..protocol import BaseProtocol +from ..protocols import BaseProtocol from .iotdevice import KasaException, requires_update from .iotplug import IotPlug from .modules import AmbientLight, Light, Motion diff --git a/kasa/iot/iotlightstrip.py b/kasa/iot/iotlightstrip.py index 14e98684..f4107b3c 100644 --- a/kasa/iot/iotlightstrip.py +++ b/kasa/iot/iotlightstrip.py @@ -5,7 +5,7 @@ from __future__ import annotations from ..device_type import DeviceType from ..deviceconfig import DeviceConfig from ..module import Module -from ..protocol import BaseProtocol +from ..protocols import BaseProtocol from .iotbulb import IotBulb from .iotdevice import requires_update from .modules.lighteffect import LightEffect diff --git a/kasa/iot/iotplug.py b/kasa/iot/iotplug.py index ab10e932..288d5376 100644 --- a/kasa/iot/iotplug.py +++ b/kasa/iot/iotplug.py @@ -8,7 +8,7 @@ from typing import Any from ..device_type import DeviceType from ..deviceconfig import DeviceConfig from ..module import Module -from ..protocol import BaseProtocol +from ..protocols import BaseProtocol from .iotdevice import IotDevice, requires_update from .modules import AmbientLight, Antitheft, Cloud, Led, Motion, Schedule, Time, Usage diff --git a/kasa/iot/iotstrip.py b/kasa/iot/iotstrip.py index a212dd61..849f92f2 100755 --- a/kasa/iot/iotstrip.py +++ b/kasa/iot/iotstrip.py @@ -14,7 +14,7 @@ from ..exceptions import KasaException from ..feature import Feature from ..interfaces import Energy from ..module import Module -from ..protocol import BaseProtocol +from ..protocols import BaseProtocol from .iotdevice import ( IotDevice, requires_update, diff --git a/kasa/protocols/__init__.py b/kasa/protocols/__init__.py new file mode 100644 index 00000000..44130d7f --- /dev/null +++ b/kasa/protocols/__init__.py @@ -0,0 +1,12 @@ +"""Package containing all supported protocols.""" + +from .iotprotocol import IotProtocol +from .protocol import BaseProtocol +from .smartprotocol import SmartErrorCode, SmartProtocol + +__all__ = [ + "BaseProtocol", + "IotProtocol", + "SmartErrorCode", + "SmartProtocol", +] diff --git a/kasa/iotprotocol.py b/kasa/protocols/iotprotocol.py similarity index 96% rename from kasa/iotprotocol.py rename to kasa/protocols/iotprotocol.py index bb570498..7e3e45a6 100755 --- a/kasa/iotprotocol.py +++ b/kasa/protocols/iotprotocol.py @@ -7,20 +7,20 @@ import logging from pprint import pformat as pf from typing import TYPE_CHECKING, Any, Callable -from .deviceconfig import DeviceConfig -from .exceptions import ( +from ..deviceconfig import DeviceConfig +from ..exceptions import ( AuthenticationError, KasaException, TimeoutError, _ConnectionError, _RetryableError, ) -from .json import dumps as json_dumps +from ..json import dumps as json_dumps +from ..transports import XorEncryption, XorTransport from .protocol import BaseProtocol, mask_mac, redact_data -from .transports import XorEncryption, XorTransport if TYPE_CHECKING: - from .transports import BaseTransport + from ..transports import BaseTransport _LOGGER = logging.getLogger(__name__) diff --git a/kasa/protocol.py b/kasa/protocols/protocol.py similarity index 84% rename from kasa/protocol.py rename to kasa/protocols/protocol.py index 8e8a2352..b879f0ae 100755 --- a/kasa/protocol.py +++ b/kasa/protocols/protocol.py @@ -12,7 +12,6 @@ http://www.apache.org/licenses/LICENSE-2.0 from __future__ import annotations -import base64 import errno import hashlib import logging @@ -22,8 +21,7 @@ from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast # When support for cpython older than 3.11 is dropped # async_timeout can be replaced with asyncio.timeout -from .credentials import Credentials -from .deviceconfig import DeviceConfig +from ..deviceconfig import DeviceConfig _LOGGER = logging.getLogger(__name__) _NO_RETRY_ERRORS = {errno.EHOSTDOWN, errno.EHOSTUNREACH, errno.ECONNREFUSED} @@ -33,7 +31,7 @@ _T = TypeVar("_T") if TYPE_CHECKING: - from .transports import BaseTransport + from ..transports import BaseTransport def redact_data(data: _T, redactors: dict[str, Callable[[Any], Any] | None]) -> _T: @@ -106,17 +104,3 @@ class BaseProtocol(ABC): @abstractmethod async def close(self) -> None: """Close the protocol. Abstract method to be overriden.""" - - -def get_default_credentials(tuple: tuple[str, str]) -> Credentials: - """Return decoded default credentials.""" - un = base64.b64decode(tuple[0].encode()).decode() - pw = base64.b64decode(tuple[1].encode()).decode() - return Credentials(un, pw) - - -DEFAULT_CREDENTIALS = { - "KASA": ("a2FzYUB0cC1saW5rLm5ldA==", "a2FzYVNldHVw"), - "TAPO": ("dGVzdEB0cC1saW5rLm5ldA==", "dGVzdA=="), - "TAPOCAMERA": ("YWRtaW4=", "YWRtaW4="), -} diff --git a/kasa/smartprotocol.py b/kasa/protocols/smartprotocol.py similarity index 99% rename from kasa/smartprotocol.py rename to kasa/protocols/smartprotocol.py index 7d43bdb4..3df8d937 100644 --- a/kasa/smartprotocol.py +++ b/kasa/protocols/smartprotocol.py @@ -14,7 +14,7 @@ import uuid from pprint import pformat as pf from typing import TYPE_CHECKING, Any, Callable -from .exceptions import ( +from ..exceptions import ( SMART_AUTHENTICATION_ERRORS, SMART_RETRYABLE_ERRORS, AuthenticationError, @@ -25,11 +25,11 @@ from .exceptions import ( _ConnectionError, _RetryableError, ) -from .json import dumps as json_dumps +from ..json import dumps as json_dumps from .protocol import BaseProtocol, mask_mac, md5, redact_data if TYPE_CHECKING: - from .transports import BaseTransport + from ..transports import BaseTransport _LOGGER = logging.getLogger(__name__) diff --git a/kasa/smart/smartchilddevice.py b/kasa/smart/smartchilddevice.py index 49c92229..c50f1f2f 100644 --- a/kasa/smart/smartchilddevice.py +++ b/kasa/smart/smartchilddevice.py @@ -8,7 +8,7 @@ from typing import Any from ..device_type import DeviceType from ..deviceconfig import DeviceConfig -from ..smartprotocol import SmartProtocol, _ChildProtocolWrapper +from ..protocols.smartprotocol import SmartProtocol, _ChildProtocolWrapper from .smartdevice import SmartDevice from .smartmodule import SmartModule diff --git a/kasa/smart/smartdevice.py b/kasa/smart/smartdevice.py index e8e2186c..b92b1c37 100644 --- a/kasa/smart/smartdevice.py +++ b/kasa/smart/smartdevice.py @@ -16,7 +16,7 @@ from ..exceptions import AuthenticationError, DeviceError, KasaException, SmartE from ..feature import Feature from ..module import Module from ..modulemapping import ModuleMapping, ModuleName -from ..smartprotocol import SmartProtocol +from ..protocols import SmartProtocol from ..transports import AesTransport from .modules import ( ChildDevice, diff --git a/kasa/transports/aestransport.py b/kasa/transports/aestransport.py index 61b7c27b..590c2f72 100644 --- a/kasa/transports/aestransport.py +++ b/kasa/transports/aestransport.py @@ -20,7 +20,7 @@ from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from yarl import URL -from kasa.credentials import Credentials +from kasa.credentials import DEFAULT_CREDENTIALS, Credentials, get_default_credentials from kasa.deviceconfig import DeviceConfig from kasa.exceptions import ( SMART_AUTHENTICATION_ERRORS, @@ -36,7 +36,6 @@ from kasa.exceptions import ( from kasa.httpclient import HttpClient from kasa.json import dumps as json_dumps from kasa.json import loads as json_loads -from kasa.protocol import DEFAULT_CREDENTIALS, get_default_credentials from .basetransport import BaseTransport diff --git a/kasa/transports/klaptransport.py b/kasa/transports/klaptransport.py index d9d5e952..49de4c54 100644 --- a/kasa/transports/klaptransport.py +++ b/kasa/transports/klaptransport.py @@ -57,16 +57,12 @@ from cryptography.hazmat.primitives import padding from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from yarl import URL -from kasa.credentials import Credentials +from kasa.credentials import DEFAULT_CREDENTIALS, Credentials, get_default_credentials from kasa.deviceconfig import DeviceConfig from kasa.exceptions import AuthenticationError, KasaException, _RetryableError from kasa.httpclient import HttpClient from kasa.json import loads as json_loads -from kasa.protocol import ( - DEFAULT_CREDENTIALS, - get_default_credentials, - md5, -) +from kasa.protocols.protocol import md5 from .basetransport import BaseTransport diff --git a/tests/fakeprotocol_iot.py b/tests/fakeprotocol_iot.py index 1249ec21..2e3d2810 100644 --- a/tests/fakeprotocol_iot.py +++ b/tests/fakeprotocol_iot.py @@ -2,7 +2,7 @@ import copy import logging from kasa.deviceconfig import DeviceConfig -from kasa.iotprotocol import IotProtocol +from kasa.protocols import IotProtocol from kasa.transports.basetransport import BaseTransport _LOGGER = logging.getLogger(__name__) diff --git a/tests/test_childdevice.py b/tests/test_childdevice.py index 05743abb..3aa605c4 100644 --- a/tests/test_childdevice.py +++ b/tests/test_childdevice.py @@ -7,9 +7,9 @@ from freezegun.api import FrozenDateTimeFactory from kasa import Device from kasa.device_type import DeviceType +from kasa.protocols.smartprotocol import _ChildProtocolWrapper from kasa.smart.smartchilddevice import SmartChildDevice from kasa.smart.smartdevice import NON_HUB_PARENT_ONLY_MODULES -from kasa.smartprotocol import _ChildProtocolWrapper from .conftest import ( parametrize, diff --git a/tests/test_klapprotocol.py b/tests/test_klapprotocol.py index bdb05490..a1521ee4 100644 --- a/tests/test_klapprotocol.py +++ b/tests/test_klapprotocol.py @@ -9,7 +9,7 @@ import aiohttp import pytest from yarl import URL -from kasa.credentials import Credentials +from kasa.credentials import DEFAULT_CREDENTIALS, Credentials, get_default_credentials from kasa.deviceconfig import DeviceConfig from kasa.exceptions import ( AuthenticationError, @@ -19,9 +19,7 @@ from kasa.exceptions import ( _RetryableError, ) from kasa.httpclient import HttpClient -from kasa.iotprotocol import IotProtocol -from kasa.protocol import DEFAULT_CREDENTIALS, get_default_credentials -from kasa.smartprotocol import SmartProtocol +from kasa.protocols import IotProtocol, SmartProtocol from kasa.transports.aestransport import AesTransport from kasa.transports.klaptransport import ( KlapEncryptionSession, diff --git a/tests/test_protocol.py b/tests/test_protocol.py index 11e2afcf..767d0f10 100644 --- a/tests/test_protocol.py +++ b/tests/test_protocol.py @@ -18,8 +18,8 @@ from kasa.device import Device from kasa.deviceconfig import DeviceConfig from kasa.exceptions import KasaException from kasa.iot import IotDevice -from kasa.iotprotocol import IotProtocol, _deprecated_TPLinkSmartHomeProtocol -from kasa.protocol import ( +from kasa.protocols.iotprotocol import IotProtocol, _deprecated_TPLinkSmartHomeProtocol +from kasa.protocols.protocol import ( BaseProtocol, mask_mac, redact_data, diff --git a/tests/test_smartdevice.py b/tests/test_smartdevice.py index 12c7349a..657fdd2f 100644 --- a/tests/test_smartdevice.py +++ b/tests/test_smartdevice.py @@ -13,10 +13,10 @@ from pytest_mock import MockerFixture from kasa import Device, KasaException, Module from kasa.exceptions import DeviceError, SmartErrorCode +from kasa.protocols.smartprotocol import _ChildProtocolWrapper from kasa.smart import SmartDevice from kasa.smart.modules.energy import Energy from kasa.smart.smartmodule import SmartModule -from kasa.smartprotocol import _ChildProtocolWrapper from .conftest import ( device_smart, @@ -266,7 +266,9 @@ async def test_update_module_query_errors( mocker.patch.object(new_dev.protocol, "query", side_effect=_query) # children not created yet so cannot patch.object - mocker.patch("kasa.smartprotocol._ChildProtocolWrapper.query", new=_child_query) + mocker.patch( + "kasa.protocols.smartprotocol._ChildProtocolWrapper.query", new=_child_query + ) await new_dev.update() @@ -297,7 +299,7 @@ async def test_update_module_query_errors( new_dev.protocol, "query", side_effect=new_dev.protocol._query ) mocker.patch( - "kasa.smartprotocol._ChildProtocolWrapper.query", + "kasa.protocols.smartprotocol._ChildProtocolWrapper.query", new=_ChildProtocolWrapper._query, ) diff --git a/tests/test_smartprotocol.py b/tests/test_smartprotocol.py index c523fcdb..180fb6aa 100644 --- a/tests/test_smartprotocol.py +++ b/tests/test_smartprotocol.py @@ -9,8 +9,8 @@ from kasa.exceptions import ( KasaException, SmartErrorCode, ) +from kasa.protocols.smartprotocol import SmartProtocol, _ChildProtocolWrapper from kasa.smart import SmartDevice -from kasa.smartprotocol import SmartProtocol, _ChildProtocolWrapper from .conftest import device_smart from .fakeprotocol_smart import FakeSmartTransport diff --git a/tests/test_sslaestransport.py b/tests/test_sslaestransport.py index 52507892..2e13f153 100644 --- a/tests/test_sslaestransport.py +++ b/tests/test_sslaestransport.py @@ -11,7 +11,7 @@ import aiohttp import pytest from yarl import URL -from kasa.credentials import Credentials +from kasa.credentials import DEFAULT_CREDENTIALS, Credentials, get_default_credentials from kasa.deviceconfig import DeviceConfig from kasa.exceptions import ( AuthenticationError, @@ -24,7 +24,6 @@ from kasa.experimental.sslaestransport import ( _sha256_hash, ) from kasa.httpclient import HttpClient -from kasa.protocol import DEFAULT_CREDENTIALS, get_default_credentials from kasa.transports.aestransport import AesEncyptionSession # Transport tests are not designed for real devices