diff --git a/src/git_jet/demo.py b/src/git_jet/demo.py index 0f36d54..64d7d0f 100644 --- a/src/git_jet/demo.py +++ b/src/git_jet/demo.py @@ -10,7 +10,33 @@ def demo_calendar(days=365): counts = { end - timedelta(days=days): (index % 7) + 1 for index, days in enumerate( - (350, 320, 123,234 ,241, 200, 201, 202, 203, 204, 99, 100, 100,292, 270, 230, 203, 175, 151, 122, 90, 61, 32, 14, 2) + ( + 350, + 320, + 123, + 234, + 241, + 200, + 201, + 202, + 203, + 204, + 99, + 100, + 100, + 292, + 270, + 230, + 203, + 175, + 151, + 122, + 90, + 61, + 32, + 14, + 2, + ) ) } return make_calendar("git-jet", end, days, counts) diff --git a/tests/test_action.py b/tests/test_action.py index 482f56c..2179156 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -7,6 +7,8 @@ import pytest +from git_jet.demo import demo_calendar + ROOT = Path(__file__).resolve().parents[1] spec = importlib.util.spec_from_file_location("action_script", ROOT / "scripts/run_action.py") action = importlib.util.module_from_spec(spec) @@ -77,6 +79,8 @@ def test_action_does_not_publish_an_output_when_collection_fails(monkeypatch, tm @pytest.mark.parametrize("carrier", ("lincoln", "classic")) @pytest.mark.parametrize("water", ("ocean", "original")) def test_actual_action_script_generates_demo_assets_and_returns_paths(tmp_path, carrier, water): + calendar = demo_calendar() + expected_dates = {day.date.isoformat() for day in calendar.days if day.commits} process = subprocess.run( [sys.executable, str(ROOT / "scripts/run_action.py")], env={ @@ -102,7 +106,9 @@ def test_actual_action_script_generates_demo_assets_and_returns_paths(tmp_path, ) assert process.returncode == 0, process.stderr report = json.loads(process.stdout) - assert report["source"] == "demo" and report["attacks"] == 14 + assert report["source"] == "demo" and report["attacks"] == len(expected_dates) + assert report["total_commits"] == calendar.total + assert {target["date"] for target in report["targets"]} == expected_dates assert report["seed"] == "action-smoke" assert report["jets"] == 3 and len(report["flights"]) == 3 assert report["carrier"] == carrier diff --git a/tests/test_auto_compress.py b/tests/test_auto_compress.py index 35dc7ac..bc37972 100644 --- a/tests/test_auto_compress.py +++ b/tests/test_auto_compress.py @@ -16,6 +16,7 @@ def test_live_render_automatically_fits_without_recollecting_or_skipping_targets monkeypatch, tmp_path, capsys ): calendar = demo_calendar() + expected_dates = {day.date.isoformat() for day in calendar.days if day.commits} collected = [] def collect(*args, **kwargs): @@ -47,9 +48,9 @@ def collect(*args, **kwargs): assert report["requested_fps"] == report["fps"] == 20 assert report["seed"] == "git-jet-loop" and report["source"] == "live" assert report["carrier"] == "lincoln" - assert report["attacks"] == report["active_days"] == 14 + assert report["attacks"] == report["active_days"] == len(expected_dates) assert sum(t["commits"] for t in report["targets"]) == calendar.total - assert len({t["date"] for t in report["targets"]}) == 14 + assert {t["date"] for t in report["targets"]} == expected_dates assert report["gif_bytes"] <= exporter.MAX_BYTES and report["decoded_frames_match"] assert json.loads((tmp_path / "report.json").read_text()) == report assert "retrying at 480x320, 20 FPS" in captured.err @@ -87,6 +88,7 @@ def test_scale_is_reduced_before_fps_with_one_fresh_seed_and_all_targets(monkeyp seeds = [] attempts = [] calendar = demo_calendar() + expected_dates = {day.date for day in calendar.days if day.commits} def fresh_seed(size): seeds.append(size) @@ -99,7 +101,8 @@ def fit(renderer, output, options, **kwargs): assert renderer.carrier == "classic" assert renderer.water == "original" assert renderer.graph_theme == "github" - assert len(renderer.flight.strikes) == 14 + assert len(renderer.flight.strikes) == len(expected_dates) + assert {s.cell.day.date for s in renderer.flight.strikes} == expected_dates assert sum(s.cell.day.commits for s in renderer.flight.strikes) == calendar.total if options.fps == 20: raise GifSizeLimitError("GIF exceeds 25 MB")