mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-23 15:58:02 +00:00
Fix discovery cli to print devices not printed during discovery timeout (#670)
* Fix discovery cli to print devices not printed during discovery * Fix tests * Fix print exceptions not being propagated * Fix tests * Reduce test discover_send time * Simplify wait logic * Add tests * Remove sleep loop and make auth failed a list
This commit is contained in:
@@ -290,7 +290,7 @@ async def test_brightness(dev):
|
||||
@device_iot
|
||||
async def test_json_output(dev: Device, mocker):
|
||||
"""Test that the json output produces correct output."""
|
||||
mocker.patch("kasa.Discover.discover", return_value=[dev])
|
||||
mocker.patch("kasa.Discover.discover", return_value={"127.0.0.1": dev})
|
||||
runner = CliRunner()
|
||||
res = await runner.invoke(cli, ["--json", "state"], obj=dev)
|
||||
assert res.exit_code == 0
|
||||
@@ -415,6 +415,26 @@ async def test_discover(discovery_mock, mocker):
|
||||
assert res.exit_code == 0
|
||||
|
||||
|
||||
async def test_discover_host(discovery_mock, mocker):
|
||||
"""Test discovery output."""
|
||||
runner = CliRunner()
|
||||
res = await runner.invoke(
|
||||
cli,
|
||||
[
|
||||
"--discovery-timeout",
|
||||
0,
|
||||
"--host",
|
||||
"127.0.0.123",
|
||||
"--username",
|
||||
"foo",
|
||||
"--password",
|
||||
"bar",
|
||||
"--verbose",
|
||||
],
|
||||
)
|
||||
assert res.exit_code == 0
|
||||
|
||||
|
||||
async def test_discover_unsupported(unsupported_device_info):
|
||||
"""Test discovery output."""
|
||||
runner = CliRunner()
|
||||
|
Reference in New Issue
Block a user