test: verify state file not updated when HTML generation fails
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user