2026-03-21 17:51:36 +01:00
|
|
|
"""Tests for brother_printer.data_classes module."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from python_pkg.brother_printer.data_classes import (
|
|
|
|
|
CUPSJob,
|
|
|
|
|
CUPSQueueStatus,
|
|
|
|
|
NetworkResult,
|
|
|
|
|
PageCountEstimate,
|
|
|
|
|
SupplyStatus,
|
|
|
|
|
USBPortStatus,
|
|
|
|
|
USBResult,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestCUPSJob:
|
|
|
|
|
def test_create(self) -> None:
|
|
|
|
|
job = CUPSJob(job_id="job-1", user="alice", size="1024", date="2025-01-01")
|
|
|
|
|
assert job.job_id == "job-1"
|
|
|
|
|
assert job.user == "alice"
|
|
|
|
|
assert job.size == "1024"
|
|
|
|
|
assert job.date == "2025-01-01"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestCUPSQueueStatus:
|
|
|
|
|
def test_defaults(self) -> None:
|
|
|
|
|
s = CUPSQueueStatus()
|
|
|
|
|
assert s.printer_name == ""
|
|
|
|
|
assert s.enabled is True
|
|
|
|
|
assert s.reason == ""
|
|
|
|
|
assert s.jobs == []
|
|
|
|
|
assert s.has_backend_errors is False
|
|
|
|
|
assert s.last_backend_error == ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestPageCountEstimate:
|
|
|
|
|
def test_defaults(self) -> None:
|
|
|
|
|
p = PageCountEstimate()
|
|
|
|
|
assert p.total_pages == 0
|
|
|
|
|
assert p.toner_pct_remaining == 100
|
|
|
|
|
assert p.drum_pct_remaining == 100
|
|
|
|
|
assert p.toner_exhausted is False
|
|
|
|
|
assert p.toner_low is False
|
|
|
|
|
assert p.drum_near_end is False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestUSBPortStatus:
|
|
|
|
|
def test_defaults(self) -> None:
|
|
|
|
|
ps = USBPortStatus()
|
|
|
|
|
assert ps.paper_empty is False
|
|
|
|
|
assert ps.online is True
|
|
|
|
|
assert ps.error is False
|
|
|
|
|
assert ps.raw_byte == 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestUSBResult:
|
|
|
|
|
def test_defaults(self) -> None:
|
|
|
|
|
r = USBResult()
|
|
|
|
|
assert r.connection == "usb"
|
|
|
|
|
assert r.device == ""
|
|
|
|
|
assert r.product == "Brother Laser Printer"
|
|
|
|
|
assert r.serial == ""
|
|
|
|
|
assert r.status_code == ""
|
|
|
|
|
assert r.display == ""
|
|
|
|
|
assert r.online == ""
|
|
|
|
|
assert r.economode == ""
|
|
|
|
|
assert r.error == ""
|
|
|
|
|
assert r.port_status is None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestNetworkResult:
|
|
|
|
|
def test_defaults(self) -> None:
|
|
|
|
|
r = NetworkResult()
|
|
|
|
|
assert r.connection == "network"
|
|
|
|
|
assert r.ip == ""
|
|
|
|
|
assert r.product == "Unknown"
|
feat: split oversized modules for 500-line limit, fix kasa coverage gap
Split diet_guard/_gatelock.py, wake_alarm/_alarm.py, and the
usage_report.py/_usage_report_parsing.py pair into focused
sub-modules so every Python file is <= 500 lines, satisfying
test_file_length.py. Install python-kasa into .venv (declared in
requirements but missing after the 3.13->3.14 venv upgrade),
fixing 8 failing smart_plug tests and restoring 100% coverage.
Also includes prior in-progress work from the working tree: the
wake_alarm Progress/View/Hardware field-grouping refactor,
brother_printer query module + tests, diet_guard foodbank/state/cli
updates, new shared coerce/logging_setup helpers, morning_routine
orchestrator tweaks, dwm window-manager config, gaming scripts, and
misc maintenance/digital-wellbeing script updates.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 07:19:37 +02:00
|
|
|
assert r.supplies.descriptions == []
|
|
|
|
|
assert r.supplies.max_values == []
|
|
|
|
|
assert r.supplies.levels == []
|
2026-03-21 17:51:36 +01:00
|
|
|
assert r.error == ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestSupplyStatus:
|
|
|
|
|
def test_create(self) -> None:
|
|
|
|
|
s = SupplyStatus(
|
|
|
|
|
color="red",
|
feat: split oversized modules for 500-line limit, fix kasa coverage gap
Split diet_guard/_gatelock.py, wake_alarm/_alarm.py, and the
usage_report.py/_usage_report_parsing.py pair into focused
sub-modules so every Python file is <= 500 lines, satisfying
test_file_length.py. Install python-kasa into .venv (declared in
requirements but missing after the 3.13->3.14 venv upgrade),
fixing 8 failing smart_plug tests and restoring 100% coverage.
Also includes prior in-progress work from the working tree: the
wake_alarm Progress/View/Hardware field-grouping refactor,
brother_printer query module + tests, diet_guard foodbank/state/cli
updates, new shared coerce/logging_setup helpers, morning_routine
orchestrator tweaks, dwm window-manager config, gaming scripts, and
misc maintenance/digital-wellbeing script updates.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 07:19:37 +02:00
|
|
|
bar_text="[###]",
|
2026-03-21 17:51:36 +01:00
|
|
|
status_text="50%",
|
|
|
|
|
warning="low",
|
|
|
|
|
needs_replacement=True,
|
|
|
|
|
)
|
|
|
|
|
assert s.color == "red"
|
|
|
|
|
assert s.needs_replacement is True
|