aboutsummaryrefslogtreecommitdiff
path: root/.ai/scripts/tests/test_drill_deck_stats.py
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-30 13:27:29 -0500
committerCraig Jennings <c@cjennings.net>2026-05-30 13:27:29 -0500
commita6313954fc297ee4a6c1c42ba903730a364cd5df (patch)
treef55cc085d966684253c6e7daaeee27593ca08801 /.ai/scripts/tests/test_drill_deck_stats.py
parent0234e52b727b34ade93961eb05b5638685f4406f (diff)
downloadrulesets-a6313954fc297ee4a6c1c42ba903730a364cd5df.tar.gz
rulesets-a6313954fc297ee4a6c1c42ba903730a364cd5df.zip
test(scripts): cover drill-to-anki internals, broadcast, and daily-prep
I backfilled the gaps left after the flashcard work landed. drill-to-anki.py had tests only for its two default helpers. I added coverage for the core parser and its pieces: parse (section-to-tag mapping, drawer-only body, blank trimming, multiline join, no-card input), strip_org_metadata (drawer and planning-line stripping, unclosed drawer), section_to_tag, escape_html, and the deterministic stable_id. I also filled the remaining drill-deck-stats / drill-deck-diff-ids branches (missing-title and PROPERTIES-mismatch warnings, the appeared-IDs note path). I added test_cross_project_broadcast.py for the two scripts that had none here: is_broadcastable / discover (SEARCH_ROOTS pointed at a tmp tree) / sender_project / inbox_send_path, plus an ERT suite for daily-prep-agenda.el (dp-iso-date, dp-bucket with the clock pinned, dp-format-entry, and dp-collect end to end on a temp org file). daily-prep-agenda.el needed one change to be loadable under ERT: its batch entrypoint fired on any load. I gated it behind dp--cli-invocation-p, the same readable-files check lint-org.el already uses, so requiring the file for tests no longer runs the extractor. A real invocation with a file argument still fires. A no-argument run now no-ops instead of printing an empty header.
Diffstat (limited to '.ai/scripts/tests/test_drill_deck_stats.py')
-rw-r--r--.ai/scripts/tests/test_drill_deck_stats.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/.ai/scripts/tests/test_drill_deck_stats.py b/.ai/scripts/tests/test_drill_deck_stats.py
index 02d9c4e..3154d42 100644
--- a/.ai/scripts/tests/test_drill_deck_stats.py
+++ b/.ai/scripts/tests/test_drill_deck_stats.py
@@ -94,3 +94,41 @@ def test_cli_dirty_deck_warns_and_exits_one(tmp_path):
def test_cli_missing_file_exits_two(tmp_path):
r = _run(tmp_path / "nope.org")
assert r.returncode == 2
+
+
+NO_TITLE_DECK = """* Section
+** What is DeepSat? :drill:
+:PROPERTIES:
+:ID: card-1
+:END:
+A satellite company.
+"""
+
+# Two cards, only one PROPERTIES drawer.
+PROP_MISMATCH_DECK = """#+TITLE: DeepSat Flashcards
+
+* Section
+** What is DeepSat? :drill:
+A satellite company.
+** Who founded it? :drill:
+:PROPERTIES:
+:ID: card-2
+:END:
+The team.
+"""
+
+
+def test_cli_missing_title_warns_and_exits_one(tmp_path):
+ f = tmp_path / "notitle.org"
+ f.write_text(NO_TITLE_DECK)
+ r = _run(f)
+ assert r.returncode == 1
+ assert "no #+TITLE" in r.stdout
+
+
+def test_cli_properties_count_mismatch_warns_and_exits_one(tmp_path):
+ f = tmp_path / "mismatch.org"
+ f.write_text(PROP_MISMATCH_DECK)
+ r = _run(f)
+ assert r.returncode == 1
+ assert "does not match card count" in r.stdout