Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions tests/cli/test_hub.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import pytest
from asyncclick.testing import CliRunner
from pytest_mock import MockerFixture

from kasa import DeviceType, Module
from kasa import Device, DeviceType, Module
from kasa.cli.hub import hub

from ..device_fixtures import hubs, plug_iot


@hubs
async def test_hub_pair(dev, mocker: MockerFixture, runner, caplog):
async def test_hub_pair(
dev: Device,
mocker: MockerFixture,
runner: CliRunner,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test that pair calls the expected methods."""
cs = dev.modules.get(Module.ChildSetup)
# Patch if the device supports the module
Expand All @@ -26,7 +32,9 @@ async def test_hub_pair(dev, mocker: MockerFixture, runner, caplog):


@hubs
async def test_hub_unpair(dev, mocker: MockerFixture, runner):
async def test_hub_unpair(
dev: Device, mocker: MockerFixture, runner: CliRunner
) -> None:
"""Test that unpair calls the expected method."""
if not dev.children:
pytest.skip("Cannot test without child devices")
Expand All @@ -44,7 +52,7 @@ async def test_hub_unpair(dev, mocker: MockerFixture, runner):


@plug_iot
async def test_non_hub(dev, mocker: MockerFixture, runner):
async def test_non_hub(dev: Device, mocker: MockerFixture, runner: CliRunner) -> None:
"""Test that hub commands return an error if executed on a non-hub."""
assert dev.device_type is not DeviceType.Hub
res = await runner.invoke(
Expand Down
21 changes: 15 additions & 6 deletions tests/cli/test_vacuum.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from asyncclick.testing import CliRunner
from pytest_mock import MockerFixture

from kasa import DeviceType, Module
from kasa import Device, DeviceType, Module
from kasa.cli.vacuum import vacuum

from ..device_fixtures import plug_iot
from ..device_fixtures import vacuum as vacuum_devices


@vacuum_devices
async def test_vacuum_records_group(dev, mocker: MockerFixture, runner):
async def test_vacuum_records_group(
dev: Device, mocker: MockerFixture, runner: CliRunner
) -> None:
"""Test that vacuum records calls the expected methods."""
rec = dev.modules.get(Module.CleanRecords)
assert rec
Expand All @@ -26,7 +29,9 @@ async def test_vacuum_records_group(dev, mocker: MockerFixture, runner):


@vacuum_devices
async def test_vacuum_records_list(dev, mocker: MockerFixture, runner):
async def test_vacuum_records_list(
dev: Device, mocker: MockerFixture, runner: CliRunner
) -> None:
"""Test that vacuum records list calls the expected methods."""
rec = dev.modules.get(Module.CleanRecords)
assert rec
Expand All @@ -46,7 +51,7 @@ async def test_vacuum_records_list(dev, mocker: MockerFixture, runner):


@vacuum_devices
async def test_vacuum_consumables(dev, runner):
async def test_vacuum_consumables(dev: Device, runner: CliRunner) -> None:
"""Test that vacuum consumables calls the expected methods."""
cons = dev.modules.get(Module.Consumables)
assert cons
Expand All @@ -62,7 +67,9 @@ async def test_vacuum_consumables(dev, runner):


@vacuum_devices
async def test_vacuum_consumables_reset(dev, mocker: MockerFixture, runner):
async def test_vacuum_consumables_reset(
dev: Device, mocker: MockerFixture, runner: CliRunner
) -> None:
"""Test that vacuum consumables reset calls the expected methods."""
cons = dev.modules.get(Module.Consumables)
assert cons
Expand All @@ -89,7 +96,9 @@ async def test_vacuum_consumables_reset(dev, mocker: MockerFixture, runner):


@plug_iot
async def test_non_vacuum(dev, mocker: MockerFixture, runner):
async def test_non_vacuum(
dev: Device, mocker: MockerFixture, runner: CliRunner
) -> None:
"""Test that vacuum commands return an error if executed on a non-vacuum."""
assert dev.device_type is not DeviceType.Vacuum

Expand Down
Loading
Loading