Skip to content

Commit 0fc7a3b

Browse files
test: cover empty-upload rejection and CLI ingest dispatch
1 parent 1e9d0a8 commit 0fc7a3b

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

tests/unit/test_cli.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ def fake_run(module: str, args: list[str]) -> int:
6262
assert "m.txt" in args
6363

6464

65+
def test_ingest_invokes_bootstrap(monkeypatch: pytest.MonkeyPatch) -> None:
66+
captured: list[tuple[str, list[str]]] = []
67+
68+
def fake_run(module: str, args: list[str]) -> int:
69+
captured.append((module, args))
70+
return 0
71+
72+
monkeypatch.setattr("src.cli._run_module", fake_run)
73+
rc = main(["ingest", "--pdf-dir", "mydocs", "--collection", "c1", "--force"])
74+
assert rc == 0
75+
module, args = captured[0]
76+
assert module == "scripts.bootstrap_corpus"
77+
assert "--pdf-dir" in args and "mydocs" in args
78+
assert "--collection" in args and "c1" in args
79+
assert "--force" in args
80+
81+
6582
def test_no_subcommand_errors() -> None:
6683
with pytest.raises(SystemExit):
6784
main([])

tests/unit/test_ingest_route.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ def test_ingest_rejects_non_pdf() -> None:
3030
assert resp.status_code == 400
3131

3232

33+
def test_ingest_rejects_empty_upload() -> None:
34+
resp = _app(enable_upload=True).post(
35+
"/ingest", files={"file": ("x.pdf", b"", "application/pdf")}
36+
)
37+
assert resp.status_code == 400
38+
39+
3340
def test_ingest_happy_path_appends_chunks(monkeypatch: pytest.MonkeyPatch) -> None:
3441
client = _app(enable_upload=True)
3542
chunks: dict[str, object] = {}

0 commit comments

Comments
 (0)