mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-01-22 12:47:05 +00:00
Fix cli discover config
This commit is contained in:
parent
7e619fcb7e
commit
faf90dde64
@ -261,8 +261,11 @@ async def config(ctx: click.Context) -> DeviceDict:
|
|||||||
host_port = host + (f":{port}" if port else "")
|
host_port = host + (f":{port}" if port else "")
|
||||||
|
|
||||||
def on_attempt(connect_attempt: ConnectAttempt, success: bool) -> None:
|
def on_attempt(connect_attempt: ConnectAttempt, success: bool) -> None:
|
||||||
prot, tran, dev = connect_attempt
|
prot, tran, dev, https = connect_attempt
|
||||||
key_str = f"{prot.__name__} + {tran.__name__} + {dev.__name__}"
|
key_str = (
|
||||||
|
f"{prot.__name__} + {tran.__name__} + {dev.__name__}"
|
||||||
|
f" + {'https' if https else 'http'}"
|
||||||
|
)
|
||||||
result = "succeeded" if success else "failed"
|
result = "succeeded" if success else "failed"
|
||||||
msg = f"Attempt to connect to {host_port} with {key_str} {result}"
|
msg = f"Attempt to connect to {host_port} with {key_str} {result}"
|
||||||
echo(msg)
|
echo(msg)
|
||||||
|
@ -146,6 +146,7 @@ class ConnectAttempt(NamedTuple):
|
|||||||
protocol: type
|
protocol: type
|
||||||
transport: type
|
transport: type
|
||||||
device: type
|
device: type
|
||||||
|
https: bool
|
||||||
|
|
||||||
|
|
||||||
class DiscoveredMeta(TypedDict):
|
class DiscoveredMeta(TypedDict):
|
||||||
|
@ -1308,11 +1308,11 @@ async def test_discover_config(dev: Device, mocker, runner):
|
|||||||
expected = f"--device-family {cparam.device_family.value} --encrypt-type {cparam.encryption_type.value} {'--https' if cparam.https else '--no-https'}"
|
expected = f"--device-family {cparam.device_family.value} --encrypt-type {cparam.encryption_type.value} {'--https' if cparam.https else '--no-https'}"
|
||||||
assert expected in res.output
|
assert expected in res.output
|
||||||
assert re.search(
|
assert re.search(
|
||||||
r"Attempt to connect to 127\.0\.0\.1 with \w+ \+ \w+ \+ \w+ failed",
|
r"Attempt to connect to 127\.0\.0\.1 with \w+ \+ \w+ \+ \w+ \+ \w+ failed",
|
||||||
res.output.replace("\n", ""),
|
res.output.replace("\n", ""),
|
||||||
)
|
)
|
||||||
assert re.search(
|
assert re.search(
|
||||||
r"Attempt to connect to 127\.0\.0\.1 with \w+ \+ \w+ \+ \w+ succeeded",
|
r"Attempt to connect to 127\.0\.0\.1 with \w+ \+ \w+ \+ \w+ \+ \w+ succeeded",
|
||||||
res.output.replace("\n", ""),
|
res.output.replace("\n", ""),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user