meshai/work/tests/test_clock_seam.py
Matt Johnson 1ffde64c3c chore(central-ripout 2d-i): relocate the fire engine + renderer out of central/
Moves the last two live files out of the retired-Central folder. central/ is
now EMPTY and deleted entirely (incl. __init__.py).

- fire-fusion engine (ingest_hotspot_pixel + the growth/cluster/spotting
  engine) → env/fire_fusion.py, next to its sole consumer env/firms.py.
- wildfire text renderer (_render + its live helpers) → env/fire_render.py.

THE COUPLING RESOLVED: firms_handler._handle_pass_boundary had a LAZY import
inside a function body — `from meshai.central.wfigs_handler import _render` —
sitting on the live FIRMS fire-growth path. It is now a normal top-of-file
import (`from meshai.env.fire_render import _render`), visible and greppable.

PURE MOVE — no behavior change:
- The parity oracle (test_fire_refactor.py) PASSES UNCHANGED (only its import
  paths updated) — proving the fire wire output is byte-for-byte identical
  before and after. Fire alerts say exactly what they said.
- handle_firms / handle_wfigs (dead entrypoints, only caller was the deleted
  consumer.py) were KEPT and moved rather than dropped — the wording-cleanup
  PR removes them deliberately. "When unsure, keep."
- fire_render.py's geo-helper imports still point at central_normalizer — that
  file's split is a SEPARATE PR; carried the imports along, did not touch it.

Consumers + test import paths rewired. Full suite: 2059 passed, 0 failed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 22:27:08 +00:00

38 lines
1.1 KiB
Python

"""Phase-0: verify the clock seam is monkeypatchable and handlers use it.
Tests:
1. clock.now() returns a float close to time.time() at runtime.
2. Monkeypatching clock.now propagates into wfigs_handler._now.
"""
import time
import pytest
import meshai.notifications.clock as clock_mod
import meshai.env.fire_render as wfigs_handler
_FROZEN_TS = 1_700_000_000.0
def test_clock_now_returns_float_close_to_time():
before = time.time()
result = clock_mod.now()
after = time.time()
assert isinstance(result, float), "clock.now() must return float"
assert before <= result <= after + 0.1, "clock.now() must be current time"
def test_clock_now_is_monkeypatchable(monkeypatch):
monkeypatch.setattr(clock_mod, "now", lambda: _FROZEN_TS)
assert clock_mod.now() == _FROZEN_TS
def test_wfigs_handler_now_uses_clock_seam(monkeypatch):
"""wfigs_handler._now() must reflect a monkeypatched clock.now."""
monkeypatch.setattr(clock_mod, "now", lambda: _FROZEN_TS)
result = wfigs_handler._now()
assert result == int(_FROZEN_TS), (
f"wfigs_handler._now() returned {result!r}, expected {int(_FROZEN_TS)}"
)