feat(growth): close same-item reconciliation loop
This commit is contained in:
@@ -261,6 +261,31 @@ def test_pchome_growth_backfill_catchup_uses_runtime_receipt_cooldown(monkeypatc
|
||||
assert reason == "stale_receipt_4.5h"
|
||||
|
||||
|
||||
def test_pchome_growth_backfill_degraded_receipt_retries_after_one_hour(monkeypatch, tmp_path):
|
||||
run_scheduler = _load_run_scheduler(monkeypatch)
|
||||
stats_path = tmp_path / "scheduler_stats.json"
|
||||
stats_path.write_text(json.dumps({
|
||||
"pchome_growth_momo_backfill": [{
|
||||
"status": "Degraded",
|
||||
"last_run": "2026-07-10 09:00:00",
|
||||
"terminal_status": "degraded_no_safe_candidate",
|
||||
}],
|
||||
}), encoding="utf-8")
|
||||
monkeypatch.setenv("SCHEDULER_STATS_PATH", str(stats_path))
|
||||
|
||||
due, reason = run_scheduler._pchome_growth_backfill_due(
|
||||
now=datetime(2026, 7, 10, 9, 30, 0)
|
||||
)
|
||||
assert due is False
|
||||
assert reason == "cooldown_1.0h"
|
||||
|
||||
due, reason = run_scheduler._pchome_growth_backfill_due(
|
||||
now=datetime(2026, 7, 10, 10, 0, 0)
|
||||
)
|
||||
assert due is True
|
||||
assert reason == "stale_receipt_1.0h"
|
||||
|
||||
|
||||
def test_pchome_growth_backfill_catchup_executes_missing_receipt(monkeypatch, tmp_path):
|
||||
run_scheduler = _load_run_scheduler(monkeypatch)
|
||||
monkeypatch.setenv("SCHEDULER_STATS_PATH", str(tmp_path / "missing.json"))
|
||||
|
||||
Reference in New Issue
Block a user