New Wi-Fi handling for SMARTCAM devices (#1639)
Some checks failed
CI / Perform Lint Checks (3.13) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
CodeQL Checks / Analyze (python) (push) Has been cancelled

Updated scanning and joining Wi-Fi for SMARTCAM devices that may use a
newer connection process.
This commit is contained in:
ZeliardM
2026-02-21 18:03:52 -05:00
committed by GitHub
parent 494db73fa8
commit 30a8fd45a8
9 changed files with 345 additions and 13 deletions

View File

@@ -49,10 +49,13 @@ from kasa.smart import SmartDevice
from kasa.smartcam import SmartCamDevice
from .conftest import (
device_iot,
device_smart,
device_smartcam,
get_device_for_fixture_protocol,
handle_turn_on,
new_discovery,
parametrize_combine,
turn_on,
)
@@ -359,12 +362,47 @@ async def test_wifi_scan(dev, runner):
assert re.search(r"Found [\d]+ wifi networks!", res.output)
@device_smart
@parametrize_combine([device_smart, device_iot])
async def test_wifi_join(dev, mocker, runner):
update = mocker.patch.object(dev, "update")
res = await runner.invoke(
wifi,
["join", "FOOBAR", "--keytype", "wpa_psk", "--password", "foobar"],
["join", "FOOBAR", "--keytype", "3", "--password", "foobar"],
obj=dev,
)
# Make sure that update was not called for wifi
with pytest.raises(AssertionError):
update.assert_called()
assert res.exit_code == 0
assert "Asking the device to connect to FOOBAR" in res.output
@parametrize_combine([device_smart, device_iot])
async def test_wifi_join_missing_keytype(dev, mocker, runner):
"""Test that missing keytype raises KasaException and CLI echoes the message."""
update = mocker.patch.object(dev, "update")
res = await runner.invoke(
wifi,
["join", "FOOBAR", "--password", "foobar"],
obj=dev,
)
# Make sure that update was not called for wifi
with pytest.raises(AssertionError):
update.assert_called()
assert res.exit_code == 0
assert "KeyType is required for this device." in res.output
@device_smartcam
async def test_wifi_join_smartcam(dev, mocker, runner):
update = mocker.patch.object(dev, "update")
res = await runner.invoke(
wifi,
["join", "FOOBAR", "--password", "foobar"],
obj=dev,
)