Files
rothmanandClaude Opus 5.5 6733aacb6e
CI / test-bookworm (push) Successful in 29s
CI / test-latest (push) Successful in 33s
Rename the Python package to daynivo_kiosk
src/voxip_kiosk -> src/daynivo_kiosk, with every import, the launchers,
install.sh, the Makefile and the manager's gunicorn app path. An upgrade
replaces /usr/lib/voxip-kiosk/python as a whole, so the old package
disappears; tested by upgrading an installation of the previous commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 23:52:39 +01:00

47 lines
2.1 KiB
Python

from daynivo_kiosk import services, sysinfo
def test_parse_throttled():
assert sysinfo.parse_throttled("throttled=0x0") == {"raw": "0x0", "now": False, "ever": False, "flags": []}
info = sysinfo.parse_throttled("throttled=0x50005")
assert info["now"] and info["ever"]
assert "Onderspanning" in info["flags"] and "Onderspanning opgetreden" in info["flags"]
assert sysinfo.parse_throttled("garbage") is None
def test_parse_ip_json_keeps_global_addresses():
data = [
{"ifname": "lo", "addr_info": [{"local": "127.0.0.1", "prefixlen": 8, "scope": "host"}]},
{"ifname": "eth0", "addr_info": [{"local": "192.168.1.5", "prefixlen": 24, "scope": "global"},
{"local": "fe80::1", "prefixlen": 64, "scope": "link"}]},
{"ifname": "wlan0", "addr_info": []},
]
assert sysinfo.parse_ip_json(data) == {"eth0": ["192.168.1.5/24"]}
def test_proc_readers(tmp_path):
(tmp_path / "uptime").write_text("3725.5 100.0\n")
(tmp_path / "meminfo").write_text("MemTotal: 1000 kB\nMemFree: 100 kB\nMemAvailable: 250 kB\n")
(tmp_path / "stat").write_text("cpu 100 0 100 800 0 0 0 0 0 0\n")
assert sysinfo.uptime_seconds(str(tmp_path)) == 3725.5
assert sysinfo.memory(str(tmp_path)) == {"total": 1024000, "used": 768000, "percent": 75.0}
assert sysinfo.cpu_percent(str(tmp_path)) is not None
def test_formatting():
assert sysinfo.format_duration(3725) == "1 u 2 min"
assert sysinfo.format_duration(90061) == "1 d 1 u 1 min"
assert sysinfo.format_bytes(1536 * 1024 * 1024) == "1,5 GB"
def test_describe_units():
assert services.describe({"ActiveState": "active"}) == ("ok", "Actief")
assert services.describe({"ActiveState": "failed"})[0] == "error"
assert services.describe({"ActiveState": "inactive", "Result": "exit-code"})[0] == "error"
assert services.describe({"ActiveState": "inactive", "Result": "success"})[0] == "stopped"
assert services.describe({})[0] == "unknown"
def test_parse_show():
assert services.parse_show("ActiveState=active\nNRestarts=3\n") == {"ActiveState": "active", "NRestarts": "3"}