25 lines
954 B
Python
25 lines
954 B
Python
|
|
from datetime import UTC, datetime
|
||
|
|
|
||
|
|
from repo_manager.freshness import summarize
|
||
|
|
|
||
|
|
|
||
|
|
def test_summarize_counts_windows_and_holes():
|
||
|
|
now = datetime(2026, 10, 4, 12, 0, tzinfo=UTC)
|
||
|
|
rows = [
|
||
|
|
{"status": "active", "last_backing_synced_at": "2026-10-04T10:00:00Z",
|
||
|
|
"forge_commit": "a"},
|
||
|
|
{"status": "active", "last_backing_synced_at": "2026-09-30T12:00:00Z",
|
||
|
|
"forge_commit": None},
|
||
|
|
{"status": "active", "last_backing_synced_at": None, "forge_commit": "b"},
|
||
|
|
{"status": "archived", "last_backing_synced_at": "2026-01-01T00:00:00Z"},
|
||
|
|
]
|
||
|
|
s = summarize(rows, now)
|
||
|
|
assert s["repos_total"] == 4
|
||
|
|
assert s["repos_active"] == 3
|
||
|
|
assert s["active_with_projection_sync"] == 2
|
||
|
|
assert s["active_never_synced_or_no_workplans"] == 1
|
||
|
|
assert s["active_forge_head_resolved"] == 2
|
||
|
|
assert s["synced_within_24h"] == 1
|
||
|
|
assert s["synced_within_7d"] == 2
|
||
|
|
assert s["age_hours"]["max"] == 96.0
|