Spaces:
Sleeping
Sleeping
Arthur_Diaz
feat(reading): add cloze (fill-in-the-blank) as a second exercise type (#5)
8a8cb44 unverified | from tutor.services.cache import FileCache | |
| def test_key_is_stable_and_separator_safe() -> None: | |
| assert FileCache.key("a", "b") == FileCache.key("a", "b") | |
| assert FileCache.key("a", "b") != FileCache.key("ab") | |
| assert FileCache.key("a", "b") != FileCache.key("a:b") | |
| def test_roundtrip_and_miss(tmp_path) -> None: | |
| cache = FileCache(tmp_path / "nested" / "dir") # created on init | |
| key = FileCache.key("text", "1", "model", "B1", "the ocean") | |
| assert cache.get(key) is None | |
| cache.set(key, {"text": "héllo", "attempts": 2}) | |
| assert cache.get(key) == {"text": "héllo", "attempts": 2} | |
| def test_corrupt_entry_behaves_like_a_miss(tmp_path) -> None: | |
| cache = FileCache(tmp_path) | |
| key = FileCache.key("x") | |
| (tmp_path / f"{key}.json").write_text("{not json", encoding="utf-8") | |
| assert cache.get(key) is None | |