mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 11:13:34 +00:00
Move protocol modules into protocols package (#1254)
This commit is contained in:
parent
1eaae37c55
commit
e55731c110
@ -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")
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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 <kasa.protocol.BaseProtocol>`
|
||||
- {class}`IotProtocol <kasa.iotprotocol.IotProtocol>`
|
||||
- {class}`SmartProtocol <kasa.smartprotocol.SmartProtocol>`
|
||||
- {class}`BaseProtocol <kasa.protocols.BaseProtocol>`
|
||||
- {class}`IotProtocol <kasa.protocols.IotProtocol>`
|
||||
- {class}`SmartProtocol <kasa.protocols.SmartProtocol>`
|
||||
|
||||
- {class}`BaseTransport <kasa.protocol.BaseTransport>`
|
||||
- {class}`XorTransport <kasa.xortransport.XorTransport>`
|
||||
- {class}`AesTransport <kasa.aestransport.AesTransport>`
|
||||
- {class}`KlapTransport <kasa.klaptransport.KlapTransport>`
|
||||
- {class}`KlapTransportV2 <kasa.klaptransport.KlapTransportV2>`
|
||||
- {class}`BaseTransport <kasa.transports.BaseTransport>`
|
||||
- {class}`XorTransport <kasa.transports.XorTransport>`
|
||||
- {class}`AesTransport <kasa.transports.AesTransport>`
|
||||
- {class}`KlapTransport <kasa.transports.KlapTransport>`
|
||||
- {class}`KlapTransportV2 <kasa.transports.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:
|
||||
|
@ -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")
|
||||
|
@ -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="),
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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__)
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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,
|
||||
|
12
kasa/protocols/__init__.py
Normal file
12
kasa/protocols/__init__.py
Normal file
@ -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",
|
||||
]
|
@ -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__)
|
||||
|
@ -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="),
|
||||
}
|
@ -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__)
|
@ -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
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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__)
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user