From ff756a7a79b13c724fc01f0db5769d58c7dda30c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 19 Nov 2023 11:08:31 -0600 Subject: [PATCH] make sure it calls discover single without type --- kasa/tests/test_cli.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/kasa/tests/test_cli.py b/kasa/tests/test_cli.py index fd76d933..49bc0f84 100644 --- a/kasa/tests/test_cli.py +++ b/kasa/tests/test_cli.py @@ -1,5 +1,4 @@ import json -import sys import asyncclick as click import pytest @@ -16,8 +15,6 @@ from kasa.cli import ( sysinfo, toggle, ) -from kasa.device_factory import DEVICE_TYPE_TO_CLASS -from kasa.device_type import DeviceType from kasa.discover import Discover from .conftest import handle_turn_on, turn_on @@ -177,6 +174,24 @@ async def test_credentials(discovery_data: dict, mocker): assert res.output == "Username:foo Password:bar\n" +async def test_without_device_type(discovery_data: dict, dev, mocker): + """Test connecting without the device type.""" + runner = CliRunner() + mocker.patch("kasa.discover.Discover.discover_single", return_value=dev) + res = await runner.invoke( + cli, + [ + "--host", + "127.0.0.1", + "--username", + "foo", + "--password", + "bar", + ], + ) + assert res.exit_code == 0 + + @pytest.mark.parametrize("auth_param", ["--username", "--password"]) async def test_invalid_credential_params(auth_param): """Test for handling only one of username or password supplied."""