Add consumables module for vacuums (#1327)
Some checks failed
CI / Perform linting checks (3.13) (push) Has been cancelled
CodeQL checks / Analyze (python) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.11) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.12) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.13) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.11) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.12) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.13) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.11) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.12) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.13) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.11) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.12) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.13) (push) Has been cancelled

Co-authored-by: Steven B <51370195+sdb9696@users.noreply.github.com>
This commit is contained in:
Teemu R.
2025-01-20 13:50:39 +01:00
committed by GitHub
parent 05085462d3
commit a03a4b1d63
7 changed files with 311 additions and 0 deletions

View File

@@ -45,6 +45,49 @@ async def test_vacuum_records_list(dev, mocker: MockerFixture, runner):
assert res.exit_code == 0
@vacuum_devices
async def test_vacuum_consumables(dev, runner):
"""Test that vacuum consumables calls the expected methods."""
cons = dev.modules.get(Module.Consumables)
assert cons
res = await runner.invoke(vacuum, ["consumables"], obj=dev, catch_exceptions=False)
expected = ""
for c in cons.consumables.values():
expected += f"{c.name} ({c.id}): {c.used} used, {c.remaining} remaining\n"
assert expected in res.output
assert res.exit_code == 0
@vacuum_devices
async def test_vacuum_consumables_reset(dev, mocker: MockerFixture, runner):
"""Test that vacuum consumables reset calls the expected methods."""
cons = dev.modules.get(Module.Consumables)
assert cons
reset_consumable_mock = mocker.spy(cons, "reset_consumable")
for c_id in cons.consumables:
reset_consumable_mock.reset_mock()
res = await runner.invoke(
vacuum, ["consumables", "reset", c_id], obj=dev, catch_exceptions=False
)
reset_consumable_mock.assert_awaited_once_with(c_id)
assert f"Consumable {c_id} reset" in res.output
assert res.exit_code == 0
res = await runner.invoke(
vacuum, ["consumables", "reset", "foobar"], obj=dev, catch_exceptions=False
)
expected = (
"Consumable foobar not found in "
f"device consumables: {', '.join(cons.consumables.keys())}."
)
assert expected in res.output.replace("\n", "")
assert res.exit_code != 0
@plug_iot
async def test_non_vacuum(dev, mocker: MockerFixture, runner):
"""Test that vacuum commands return an error if executed on a non-vacuum."""
@@ -59,3 +102,13 @@ async def test_non_vacuum(dev, mocker: MockerFixture, runner):
)
assert "This device does not support records" in res.output
assert res.exit_code != 0
res = await runner.invoke(vacuum, ["consumables"], obj=dev, catch_exceptions=False)
assert "This device does not support consumables" in res.output
assert res.exit_code != 0
res = await runner.invoke(
vacuum, ["consumables", "reset", "foobar"], obj=dev, catch_exceptions=False
)
assert "This device does not support consumables" in res.output
assert res.exit_code != 0