nws: rewrite _render() to 4-line format with SAME-branched hazard and motion

New wire format:
  L1: emoji + event type (no office name)
  L2: NWSheadline (title-cased, 80 chars) or "{event} for {area}" fallback
  L3: SAME-code-branched hazard + certainty/threat:
      TOR: on-ground/radar + damage threat
      SVR: wind/hail + radar confirmed/indicated
      FFW/FLW: hazard sentence + inferred flood cause
      Others: hazard sentence + certainty if Observed/Likely
  L4: motion (compass + mph from eventMotionDescription) + locations

Drop expires, area/county, and impact lines. Add _parse_motion() helper
for eventMotionDescription (knots -> mph conversion). Add "locations"
pattern to _parse_nws_description(). Update test to remove expires check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt Johnson (via Claude) 2026-06-08 07:05:22 +00:00
commit a4ecd05c60
2 changed files with 92 additions and 33 deletions

View file

@ -194,9 +194,8 @@ def test_commit_callback_updates_last_broadcast(mem_db):
assert el["handled"] == 1
def test_wire_includes_event_area_and_expires(mem_db):
def test_wire_includes_event_and_headline(mem_db):
env = _nws_env(severity_str="Severe", lat=42.500, lon=-114.460)
wire = handle_nws(env, env["subject"], data={}, now=1_000_000)
assert "Severe Thunderstorm Warning" in wire
assert "Twin Falls County" in wire
assert "until" in wire.lower()