MIL-003: Step 2 - New flash cards

Review record RC-025 (Go, autonomous mode, not independent).

Task: MIL-003#1
Task: MIL-003#2
Task: MIL-003#3
Task: MIL-003#4
Task: MIL-003#5
This commit is contained in:
2026-10-14 21:59:29 +08:00
parent c6c737ce40
commit 8d66c43eea
36 changed files with 1167 additions and 102 deletions
+19 -3
View File
@@ -4,6 +4,8 @@
@brief Checks main of flash_card.presentation.app without opening a window.
"""
from pathlib import Path
import pytest
from flash_card.presentation import app
@@ -18,10 +20,24 @@ class _FakeRoot:
def test_main_runs_main_loop_and_returns_zero(
monkeypatch: pytest.MonkeyPatch,
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
root = _FakeRoot()
monkeypatch.setattr(app, "create_application", lambda: (root, object()))
seen: list[Path | None] = []
assert app.main([]) == 0
def fake_create(data_dir: Path | None = None) -> tuple[_FakeRoot, object]:
seen.append(data_dir)
return root, object()
monkeypatch.setattr(app, "create_application", fake_create)
assert app.main(["--data-dir", str(tmp_path)]) == 0
assert root.mainloop_calls == 1
assert seen == [tmp_path]
def test_main_returns_one_when_word_list_is_missing(
tmp_path: Path, caplog: pytest.LogCaptureFixture
) -> None:
assert app.main(["--data-dir", str(tmp_path / "nowhere")]) == 1
assert "word list not found" in caplog.text