Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/git_jet/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 7 additions & 1 deletion tests/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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={
Expand All @@ -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
Expand Down
9 changes: 6 additions & 3 deletions tests/test_auto_compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand Down
Loading