- migration 20261018170000: pgmq badge_print/badge_print_dlq, print_stations, token-gated printer RPCs (claim/complete/fail/heartbeat), admin RPCs, welcome_checkin enqueue; badge_print_tests.sql (101 assertions) - apps/printer: Python worker (Playwright render -> brother_ql via pyusb), comitup captive-portal (Wi-Fi + HTTPS endpoint + anon key + token), arm64 image build + idempotent Pi setup/install scripts, 77 pytest - apps/admin: Printing view, station management/DLQ, global printer status pill, Print button on Registrations, standalone print renderer entry (print.html -> dist-print) with bundled fonts - docs: printing.md + architecture/schema/rpcs/tests/admin-app updates, apps/printer/AGENT.md operating manual - e2e: printing.spec.ts
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
from worker.network import read_network
|
|
|
|
|
|
def test_missing_file_falls_back(tmp_path):
|
|
result = read_network(str(tmp_path / "absent.json"))
|
|
assert result["state"] == "UNKNOWN"
|
|
assert result["ssid"] is None
|
|
assert "ip" in result
|
|
|
|
|
|
def test_reads_state(tmp_path):
|
|
path = tmp_path / "network.json"
|
|
path.write_text(json.dumps({"state": "CONNECTED", "ssid": "office", "ip": "10.0.0.9", "updated_at": "x"}))
|
|
result = read_network(str(path))
|
|
assert result["state"] == "CONNECTED"
|
|
assert result["ssid"] == "office"
|
|
assert result["ip"] == "10.0.0.9"
|
|
|
|
|
|
def test_corrupt_file_falls_back(tmp_path):
|
|
path = tmp_path / "network.json"
|
|
path.write_text("{not json")
|
|
assert read_network(str(path))["state"] == "UNKNOWN"
|
|
|
|
|
|
def test_empty_strings_become_none(tmp_path):
|
|
path = tmp_path / "network.json"
|
|
path.write_text(json.dumps({"state": "HOTSPOT", "ssid": "", "ip": ""}))
|
|
result = read_network(str(path))
|
|
assert result["state"] == "HOTSPOT"
|
|
assert result["ssid"] is None
|
|
assert result["ip"] is None
|