| from cache import AnswerCache, ResultStore | |
| def test_cache_round_trip_and_run_resume(tmp_path): | |
| cache = AnswerCache(tmp_path / "answers.json") | |
| cache.put("one", {"answer": "A"}) | |
| assert cache.get("one") == {"answer": "A"} | |
| run = AnswerCache(tmp_path / "run.json") | |
| rows = [{"task_id": "1", "status": "ok"}] | |
| run.save_run(rows) | |
| assert run.load_run() == rows | |
| def test_task_keyed_result_store(tmp_path): | |
| store = ResultStore(tmp_path / "results.json") | |
| store.save_result("b", {"task_id": "b", "status": "ok"}) | |
| store.save_result("a", {"task_id": "a", "status": "ok"}) | |
| assert set(store.load()) == {"a", "b"} | |
| assert [row["task_id"] for row in store.ordered(["a", "b"])] == ["a", "b"] | |
| store.remove("a") | |
| assert "a" not in store.load() | |