mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-11 18:08:02 +00:00
Update test framework to support smartcam device discovery. (#1477)
Update test framework to support `smartcam` device discovery: - Add `SMARTCAM` to the default `discovery_mock` filter - Make connection parameter derivation a self contained static method in `Discover` - Introduce a queue to the `discovery_mock` to ensure the discovery callbacks complete in the same order that they started. - Patch `Discover._decrypt_discovery_data` in `discovery_mock` so it doesn't error trying to decrypt empty fixture data
This commit is contained in:
@@ -60,13 +60,7 @@ def _get_connection_type_device_class(discovery_info):
|
||||
device_class = Discover._get_device_class(discovery_info)
|
||||
dr = DiscoveryResult.from_dict(discovery_info["result"])
|
||||
|
||||
connection_type = DeviceConnectionParameters.from_values(
|
||||
dr.device_type,
|
||||
dr.mgt_encrypt_schm.encrypt_type,
|
||||
login_version=dr.mgt_encrypt_schm.lv,
|
||||
https=dr.mgt_encrypt_schm.is_support_https,
|
||||
http_port=dr.mgt_encrypt_schm.http_port,
|
||||
)
|
||||
connection_type = Discover._get_connection_parameters(dr)
|
||||
else:
|
||||
connection_type = DeviceConnectionParameters.from_values(
|
||||
DeviceFamily.IotSmartPlugSwitch.value, DeviceEncryptionType.Xor.value
|
||||
@@ -118,11 +112,7 @@ async def test_connect_custom_port(discovery_mock, mocker, custom_port):
|
||||
connection_type=ctype,
|
||||
credentials=Credentials("dummy_user", "dummy_password"),
|
||||
)
|
||||
default_port = (
|
||||
DiscoveryResult.from_dict(discovery_data["result"]).mgt_encrypt_schm.http_port
|
||||
if "result" in discovery_data
|
||||
else 9999
|
||||
)
|
||||
default_port = discovery_mock.default_port
|
||||
|
||||
ctype, _ = _get_connection_type_device_class(discovery_data)
|
||||
|
||||
|
Reference in New Issue
Block a user