EdgeWatch/tests
Richard Nixon 9413797a51 test: cover Settings validation and Metrics schema
34 new tests (89 total, still ~0.1s).

test_settings.py — exercises BackendSettings directly with _env_file=None
so the developer's local .env does not leak in:
  - default port ranges and invariants,
  - non-integer / out-of-range port rejection,
  - cpu_alert_th out-of-range rejection,
  - env override roundtrip,
  - extra="ignore" tolerates typos (regression: an unknown env var
    should not crash startup).

test_metrics_schema.py — black-box tests of parse_metrics() with each
case named after the attack it guards against:
  - happy path with full and partial (optional fields) payloads,
  - every required field individually missing,
  - every percentage field individually out of [0, 100],
  - extra="forbid" rejects smuggled keys (e.g. {"injected": "<!channel>"}),
  - unsafe device_id patterns (slashes, newlines, path traversal,
    65-char overflow, empty string),
  - invalid raw JSON,
  - NaN / Infinity / -Infinity which json.loads accepts but the
    schema (Field + the finite-value validator) rejects.
2026-05-17 17:19:50 +01:00
..
__init__.py test: add pytest suite for validation, alerting and WS auth 2026-05-17 14:45:00 +00:00
conftest.py test: add pytest suite for validation, alerting and WS auth 2026-05-17 14:45:00 +00:00
test_active_snapshot.py test: add pytest suite for validation, alerting and WS auth 2026-05-17 14:45:00 +00:00
test_alert_predicate.py test: add pytest suite for validation, alerting and WS auth 2026-05-17 14:45:00 +00:00
test_backoff.py feat(backend): reconnect MQTT with exponential backoff 2026-05-17 16:24:10 +01:00
test_metrics_schema.py test: cover Settings validation and Metrics schema 2026-05-17 17:19:50 +01:00
test_settings.py test: cover Settings validation and Metrics schema 2026-05-17 17:19:50 +01:00
test_validation.py test: add pytest suite for validation, alerting and WS auth 2026-05-17 14:45:00 +00:00
test_ws_token.py feat(config): typed settings via pydantic-settings 2026-05-17 17:19:50 +01:00