fix: handle OSError in save methods, add missing test, consistent logging
- Wrap save_snapshot_cache and save_last_run_date in try/except OSError, logging a warning instead of propagating the exception - Add indent=2 to save_last_run_date for consistency - Add warning log to load_last_run_date on read failure (matching load_snapshot_cache pattern) - Add test_load_last_run_date_missing_key_returns_none covering valid JSON with absent key - Remove unused asyncio, AsyncMock, and patch imports from test file Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import asyncio
|
||||
import json
|
||||
import pytest
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from src.snapshot_downloader import SnapshotDownloader
|
||||
|
||||
@@ -63,6 +61,12 @@ def test_load_last_run_date_malformed_returns_none(tmp_path):
|
||||
assert d.load_last_run_date() is None
|
||||
|
||||
|
||||
def test_load_last_run_date_missing_key_returns_none(tmp_path):
|
||||
d = _downloader(tmp_path)
|
||||
(tmp_path / "last_run.json").write_text('{"date": "2025-01-01"}')
|
||||
assert d.load_last_run_date() is None
|
||||
|
||||
|
||||
# --- save_last_run_date ---
|
||||
|
||||
def test_save_last_run_date_writes_json(tmp_path):
|
||||
|
||||
Reference in New Issue
Block a user