Commit graph

3 commits

Author SHA1 Message Date
google-labs-jules[bot]
632c5cba01 test: add missing keys coverage for alerting payload builder
Adds `test_build_payload_missing_keys_serializable` to verify that `build_payload` correctly handles scenarios where input dictionaries lack expected keys. Tests that `dict.get()` fallbacks safely map to `None` and empty lists without causing tracebacks or JSON serialization issues.

Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
2026-10-07 03:54:25 +00:00
Horizontal42
44ca9c1786
Add tests for _os_timezone function (#22)
This commit adds a new test file, `tests/test_cli.py`, containing
unit tests for the `_os_timezone` function in `netsleuth.cli`.

The tests cover:
- Happy paths (TZ variable, /etc/localtime symlink, /etc/timezone file)
- The edge case of an `OSError` exception being thrown when reading the
  /etc/timezone file.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-08-19 16:40:44 +03:00
Andrew Pimenov
e27ccdfab5 give --watch a per-tick verdict and optional webhook alerts
watch.py never imported interpret and had no notion of a verdict at all -
summarize_cycle() now runs the same latency_findings/speed_findings/
overall_verdict pipeline the one-shot report uses, so every tick carries
status/score/finding_ids and the dashboard caption shows a verdict line.
Real improvement on its own, independent of whether a webhook exists.

New alerting.py carries the whole notification contract as pure functions:
should_fire() only fires on an actual transition, into a state the user
opted into via watch.webhook_on, debounced by
watch.webhook_min_interval_seconds (floored at 30 in a validator) so a
flapping link can't spam an endpoint every tick. Recovery is its own
opt-in "recovered" token, separate from configuring "crit", since wanting
outage alerts doesn't imply wanting a second ping when they clear.
build_payload() is flat JSON, not shaped for Slack/Discord - that's the
receiver's problem. post_webhook() swallows every failure and returns a
bool; a dead endpoint must never interrupt the loop watching it.

New --webhook URL flag overrides watch.webhook_url per run.

Verified the tick sequence end-to-end outside the Rich Live loop -
sending real OS signals to test --watch's Ctrl-C handling in this shell
wasn't reliable, so exercised should_fire/build_payload/render_dashboard/
to_report in the same order run_watch calls them.

Part of plans/zesty-zooming-wilkinson.md (gitignored).
2026-08-12 22:26:31 +03:00