2026-06-16 01:21:01 +02:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
2026-06-16 02:09:57 +02:00
|
|
|
from reuse_surface.stats import (
|
|
|
|
|
collect_roster_stats,
|
|
|
|
|
collect_stats,
|
|
|
|
|
format_roster_stats_markdown,
|
|
|
|
|
format_stats_markdown,
|
|
|
|
|
)
|
2026-06-16 01:21:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_collect_stats_on_repo_root():
|
|
|
|
|
root = Path(__file__).resolve().parent.parent
|
|
|
|
|
stats = collect_stats(root)
|
2026-06-16 12:35:49 +02:00
|
|
|
assert stats["capability_count"] == 2
|
2026-06-16 01:21:01 +02:00
|
|
|
assert stats["index_present"] is True
|
|
|
|
|
assert "discovery" in stats["histograms"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_format_stats_markdown_contains_count():
|
|
|
|
|
root = Path(__file__).resolve().parent.parent
|
|
|
|
|
text = format_stats_markdown(collect_stats(root))
|
|
|
|
|
assert "Capabilities:" in text
|
2026-06-16 12:35:49 +02:00
|
|
|
assert "2" in text
|
2026-06-16 02:09:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_collect_roster_stats_federation_ready():
|
|
|
|
|
root = Path(__file__).resolve().parent.parent
|
|
|
|
|
roster = root / "registry/federation/local-repo-roster.yaml"
|
|
|
|
|
stats = collect_roster_stats(roster, federation_ready=True)
|
|
|
|
|
assert stats["counts"]["total"] == 60
|
|
|
|
|
assert stats["counts"]["established"] == 60
|
|
|
|
|
assert "federation_readiness" in stats
|
|
|
|
|
text = format_roster_stats_markdown(stats)
|
|
|
|
|
assert "publish pass ratio" in text
|