mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-12 10:28:01 +00:00
Use _get_device_info methods for smart and iot devs in devtools (#1265)
This commit is contained in:
@@ -188,11 +188,12 @@ def parametrize(
|
||||
data_root_filter=None,
|
||||
device_type_filter=None,
|
||||
ids=None,
|
||||
fixture_name="dev",
|
||||
):
|
||||
if ids is None:
|
||||
ids = idgenerator
|
||||
return pytest.mark.parametrize(
|
||||
"dev",
|
||||
fixture_name,
|
||||
filter_fixtures(
|
||||
desc,
|
||||
model_filter=model_filter,
|
||||
@@ -407,22 +408,28 @@ async def _discover_update_and_close(ip, username, password) -> Device:
|
||||
return await _update_and_close(d)
|
||||
|
||||
|
||||
async def get_device_for_fixture(fixture_data: FixtureInfo) -> Device:
|
||||
async def get_device_for_fixture(
|
||||
fixture_data: FixtureInfo, *, verbatim=False, update_after_init=True
|
||||
) -> Device:
|
||||
# if the wanted file is not an absolute path, prepend the fixtures directory
|
||||
|
||||
d = device_for_fixture_name(fixture_data.name, fixture_data.protocol)(
|
||||
host="127.0.0.123"
|
||||
)
|
||||
if fixture_data.protocol in {"SMART", "SMART.CHILD"}:
|
||||
d.protocol = FakeSmartProtocol(fixture_data.data, fixture_data.name)
|
||||
d.protocol = FakeSmartProtocol(
|
||||
fixture_data.data, fixture_data.name, verbatim=verbatim
|
||||
)
|
||||
elif fixture_data.protocol == "SMARTCAMERA":
|
||||
d.protocol = FakeSmartCameraProtocol(fixture_data.data, fixture_data.name)
|
||||
d.protocol = FakeSmartCameraProtocol(
|
||||
fixture_data.data, fixture_data.name, verbatim=verbatim
|
||||
)
|
||||
else:
|
||||
d.protocol = FakeIotProtocol(fixture_data.data)
|
||||
d.protocol = FakeIotProtocol(fixture_data.data, verbatim=verbatim)
|
||||
|
||||
discovery_data = None
|
||||
if "discovery_result" in fixture_data.data:
|
||||
discovery_data = {"result": fixture_data.data["discovery_result"]}
|
||||
discovery_data = fixture_data.data["discovery_result"]
|
||||
elif "system" in fixture_data.data:
|
||||
discovery_data = {
|
||||
"system": {"get_sysinfo": fixture_data.data["system"]["get_sysinfo"]}
|
||||
@@ -431,7 +438,8 @@ async def get_device_for_fixture(fixture_data: FixtureInfo) -> Device:
|
||||
if discovery_data: # Child devices do not have discovery info
|
||||
d.update_from_discover_info(discovery_data)
|
||||
|
||||
await _update_and_close(d)
|
||||
if update_after_init:
|
||||
await _update_and_close(d)
|
||||
return d
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user