Compare commits

..

3 Commits

Author SHA1 Message Date
imple d1e096b13f Add explanations for the rest of A-class questions 2026-05-23 12:51:42 +02:00
imple 81b70123bf Update tests to check explanations JSON 2026-05-23 12:14:07 +02:00
imple e5af931c0a Touch up some explanations 2026-05-23 12:13:27 +02:00
2 changed files with 1888 additions and 16 deletions
+1864 -16
View File
File diff suppressed because it is too large Load Diff
+24
View File
@@ -489,5 +489,29 @@ class TestAnkiBuild(unittest.TestCase):
self.assertEqual(first.read_bytes(), second.read_bytes(), first.name)
class TestRealExplanationsFile(unittest.TestCase):
"""Validate the repo's actual explanations.json against the live catalog.
The other tests are hermetic by design: they exercise the schema
validator on synthetic fixtures so the validator's own logic is
tested without coupling to editorial data. That leaves a gap — a
real malformed entry or stale key in the repo's explanations.json
would not show up in `python3 -m unittest`. This test closes it
when the fetched catalog is present, and skips otherwise so an
unfetched checkout still runs the rest of the suite.
"""
def test_repo_explanations_pass_schema_and_match_catalog(self):
repo = Path(__file__).resolve().parent
explanations_path = repo / "explanations.json"
catalogs = sorted((repo / "data").glob("*/fragenkatalog*.json"))
if not explanations_path.exists() or not catalogs:
self.skipTest("explanations.json or fetched catalog not available")
explanations = aa.load_explanations(explanations_path)
catalog = json.loads(catalogs[-1].read_text("utf-8"))
categories = aa.collect_categories(catalog)
aa._check_explanation_keys_against_catalog(explanations, categories)
if __name__ == "__main__":
unittest.main()