mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Add P300 fixture (#717)
* Add P300 fixture * fixture after update * Add tests for p300
This commit is contained in:
@@ -13,15 +13,18 @@ import pytest # type: ignore # see https://github.com/pytest-dev/pytest/issues/
|
||||
|
||||
from kasa import (
|
||||
Credentials,
|
||||
DeviceConfig,
|
||||
Discover,
|
||||
SmartBulb,
|
||||
SmartDevice,
|
||||
SmartDimmer,
|
||||
SmartLightStrip,
|
||||
SmartPlug,
|
||||
SmartProtocol,
|
||||
SmartStrip,
|
||||
)
|
||||
from kasa.tapo import TapoBulb, TapoDevice, TapoPlug
|
||||
from kasa.protocol import BaseTransport
|
||||
from kasa.tapo import TapoBulb, TapoPlug
|
||||
from kasa.xortransport import XorEncryption
|
||||
|
||||
from .newfakes import FakeSmartProtocol, FakeTransportProtocol
|
||||
@@ -107,7 +110,7 @@ PLUGS = {
|
||||
*PLUGS_SMART,
|
||||
}
|
||||
STRIPS_IOT = {"HS107", "HS300", "KP303", "KP200", "KP400", "EP40"}
|
||||
STRIPS_SMART: Set[str] = set()
|
||||
STRIPS_SMART = {"P300"}
|
||||
STRIPS = {*STRIPS_IOT, *STRIPS_SMART}
|
||||
|
||||
DIMMERS_IOT = {"ES20M", "HS220", "KS220M", "KS230", "KP405"}
|
||||
@@ -210,7 +213,7 @@ no_emeter_iot = parametrize(
|
||||
|
||||
bulb = parametrize("bulbs", BULBS, protocol_filter={"SMART", "IOT"})
|
||||
plug = parametrize("plugs", PLUGS, protocol_filter={"IOT"})
|
||||
strip = parametrize("strips", STRIPS, protocol_filter={"IOT"})
|
||||
strip = parametrize("strips", STRIPS, protocol_filter={"SMART", "IOT"})
|
||||
dimmer = parametrize("dimmers", DIMMERS, protocol_filter={"IOT"})
|
||||
lightstrip = parametrize("lightstrips", LIGHT_STRIPS, protocol_filter={"IOT"})
|
||||
|
||||
@@ -238,6 +241,11 @@ variable_temp_iot = parametrize(
|
||||
)
|
||||
bulb_iot = parametrize("bulb devices iot", BULBS_IOT, protocol_filter={"IOT"})
|
||||
|
||||
strip_iot = parametrize("strip devices iot", STRIPS_IOT, protocol_filter={"IOT"})
|
||||
strip_smart = parametrize(
|
||||
"strip devices smart", STRIPS_SMART, protocol_filter={"SMART"}
|
||||
)
|
||||
|
||||
plug_smart = parametrize("plug devices smart", PLUGS_SMART, protocol_filter={"SMART"})
|
||||
bulb_smart = parametrize("bulb devices smart", BULBS_SMART, protocol_filter={"SMART"})
|
||||
dimmers_smart = parametrize(
|
||||
@@ -338,6 +346,9 @@ def device_for_file(model, protocol):
|
||||
for d in DIMMERS_SMART:
|
||||
if d in model:
|
||||
return TapoBulb
|
||||
for d in STRIPS_SMART:
|
||||
if d in model:
|
||||
return TapoPlug
|
||||
else:
|
||||
for d in STRIPS_IOT:
|
||||
if d in model:
|
||||
@@ -556,6 +567,34 @@ def unsupported_device_info(request, mocker):
|
||||
yield discovery_data
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def dummy_protocol():
|
||||
"""Return a smart protocol instance with a mocking-ready dummy transport."""
|
||||
|
||||
class DummyTransport(BaseTransport):
|
||||
@property
|
||||
def default_port(self) -> int:
|
||||
return -1
|
||||
|
||||
@property
|
||||
def credentials_hash(self) -> str:
|
||||
return "dummy hash"
|
||||
|
||||
async def send(self, request: str) -> Dict:
|
||||
return {}
|
||||
|
||||
async def close(self) -> None:
|
||||
pass
|
||||
|
||||
async def reset(self) -> None:
|
||||
pass
|
||||
|
||||
transport = DummyTransport(config=DeviceConfig(host="127.0.0.123"))
|
||||
protocol = SmartProtocol(transport=transport)
|
||||
|
||||
return protocol
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
"--ip", action="store", default=None, help="run against device on given ip"
|
||||
|
Reference in New Issue
Block a user