mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Add factory-reset command to cli (#1108)
Allow reseting devices to factory settings using the cli: `kasa device factory-reset`.
This commit is contained in:
parent
f07341a5a6
commit
b7fa0d2040
@ -166,6 +166,17 @@ async def reboot(plug, delay):
|
|||||||
return await plug.reboot(delay)
|
return await plug.reboot(delay)
|
||||||
|
|
||||||
|
|
||||||
|
@device.command()
|
||||||
|
@pass_dev
|
||||||
|
async def factory_reset(plug):
|
||||||
|
"""Reset device to factory settings."""
|
||||||
|
click.confirm(
|
||||||
|
"Do you really want to reset the device to factory settings?", abort=True
|
||||||
|
)
|
||||||
|
|
||||||
|
return await plug.factory_reset()
|
||||||
|
|
||||||
|
|
||||||
@device.command()
|
@device.command()
|
||||||
@pass_dev
|
@pass_dev
|
||||||
@click.option(
|
@click.option(
|
||||||
|
@ -19,6 +19,7 @@ from kasa import (
|
|||||||
)
|
)
|
||||||
from kasa.cli.device import (
|
from kasa.cli.device import (
|
||||||
alias,
|
alias,
|
||||||
|
factory_reset,
|
||||||
led,
|
led,
|
||||||
reboot,
|
reboot,
|
||||||
state,
|
state,
|
||||||
@ -215,6 +216,21 @@ async def test_reboot(dev, mocker, runner):
|
|||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
|
|
||||||
|
|
||||||
|
@device_smart
|
||||||
|
async def test_factory_reset(dev, mocker, runner):
|
||||||
|
"""Test that factory reset works on SMART devices."""
|
||||||
|
query_mock = mocker.patch.object(dev.protocol, "query")
|
||||||
|
|
||||||
|
res = await runner.invoke(
|
||||||
|
factory_reset,
|
||||||
|
obj=dev,
|
||||||
|
input="y\n",
|
||||||
|
)
|
||||||
|
|
||||||
|
query_mock.assert_called()
|
||||||
|
assert res.exit_code == 0
|
||||||
|
|
||||||
|
|
||||||
@device_smart
|
@device_smart
|
||||||
async def test_wifi_scan(dev, runner):
|
async def test_wifi_scan(dev, runner):
|
||||||
res = await runner.invoke(wifi, ["scan"], obj=dev)
|
res = await runner.invoke(wifi, ["scan"], obj=dev)
|
||||||
|
Loading…
Reference in New Issue
Block a user