From 778ae47ebed4d0e97e1fa1bdc7b80362925711d5 Mon Sep 17 00:00:00 2001 From: Tudor Sitaru Date: Sat, 16 May 2026 20:26:10 +0100 Subject: [PATCH] test: verify state file not updated when HTML generation fails Co-Authored-By: Claude Sonnet 4.6 --- tests/test_incremental_snapshot.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_incremental_snapshot.py b/tests/test_incremental_snapshot.py index c7076e9..7ee40c5 100644 --- a/tests/test_incremental_snapshot.py +++ b/tests/test_incremental_snapshot.py @@ -157,3 +157,19 @@ def test_fetch_failure_does_not_update_state(tmp_path): assert d.load_last_run_date() == "2025-01-01" assert d.load_snapshot_cache() == [{"id": "existing"}] + + +def test_html_generation_failure_does_not_update_state_file(tmp_path): + d = _downloader(tmp_path) + d.save_last_run_date("2025-01-01") + d.save_snapshot_cache([{"id": "existing"}]) + new_snapshots = [{"id": "new", "startTime": "2025-02-01T00:00:00Z"}] + with patch.object(d, "authenticate", new_callable=AsyncMock): + with patch.object(d, "fetch_all_snapshots", new_callable=AsyncMock, + return_value=new_snapshots): + with patch.object(d, "generate_html_file", new_callable=AsyncMock, + side_effect=OSError("disk full")): + with pytest.raises(OSError): + asyncio.run(d.download_snapshots(date_from="2024-01-01")) + # Cache was updated with new data, but state file was NOT advanced + assert d.load_last_run_date() == "2025-01-01"