"""ST-01~04: Storage — DiskCache / ReportStore / TestDataBundle""" import sys, os, tempfile, json from pathlib import Path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) from storage.store import DiskCache, ReportStore from storage.bundle import TestDataBundle def test_disk_cache_set_get(): """ST-01: set/get 一致""" with tempfile.TemporaryDirectory() as tmp: c = DiskCache(d=tmp) c.set("key1", {"val": 42}) assert c.get("key1") == {"val": 42} def test_disk_cache_get_missing(): """ST-02: 未缓存 → None""" with tempfile.TemporaryDirectory() as tmp: c = DiskCache(d=tmp) assert c.get("unknown") is None def test_report_store_save(): """ST-03: save_history 写入""" with tempfile.TemporaryDirectory() as tmp: s = ReportStore(base=tmp) s.save_history("TESTPGM", "PASS", 5, 0.5) trend_dir = Path(tmp) / "trends" assert trend_dir.exists() files = list(trend_dir.glob("*.jsonl")) assert len(files) >= 1 def test_bundle_paths(): """ST-04: TestDataBundle 路径""" with tempfile.TemporaryDirectory() as tmp: b = TestDataBundle(base_path=Path(tmp)) assert "cobol" in str(b.cobol_input()) assert "spark" in str(b.spark_input_dir()) assert "native" in str(b.native_input())