VoxIP Kiosk OS 1.0.0: Raspberry Pi kiosk with web management
Chromium kiosk without a desktop for the Raspberry Pi 3, a Flask web interface on port 8080 (kiosk, system and network management), a restricted root helper, network changes with automatic rollback, a healthcheck timer, install/update/uninstall scripts and a pi-gen image build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
a33c4822bf
96 files changed
+7535
No files matched your search
@@ -0,0 +1,46 @@
|
||||
from voxip_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"}
|
||||
Reference in new issue
Block a user