50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
import pytest
|
|
|
|
from ingestion.cli import build_parser
|
|
|
|
|
|
def test_run_subcommand_parses_required_pdf_arg():
|
|
parser = build_parser()
|
|
args = parser.parse_args(["run", "--pdf", "some.pdf"])
|
|
assert args.command == "run"
|
|
assert args.pdf == "some.pdf"
|
|
assert args.out == "data/processed/monographs.jsonl"
|
|
|
|
|
|
def test_run_subcommand_accepts_custom_out():
|
|
parser = build_parser()
|
|
args = parser.parse_args(["run", "--pdf", "a.pdf", "--out", "b.jsonl"])
|
|
assert args.out == "b.jsonl"
|
|
|
|
|
|
def test_run_requires_pdf_arg():
|
|
parser = build_parser()
|
|
with pytest.raises(SystemExit):
|
|
parser.parse_args(["run"])
|
|
|
|
|
|
@pytest.mark.parametrize("command", ["visual-diff", "scaffold-golden"])
|
|
def test_not_yet_implemented_commands_raise_explicitly(command):
|
|
parser = build_parser()
|
|
args = parser.parse_args([command])
|
|
with pytest.raises(NotImplementedError):
|
|
args.func(args)
|
|
|
|
|
|
def test_run_reports_missing_pdf_file(tmp_path, capsys):
|
|
parser = build_parser()
|
|
missing = tmp_path / "does_not_exist.pdf"
|
|
args = parser.parse_args(["run", "--pdf", str(missing)])
|
|
exit_code = args.func(args)
|
|
assert exit_code == 1
|
|
assert "not found" in capsys.readouterr().err
|
|
|
|
|
|
def test_validate_reports_missing_pdf_file(tmp_path, capsys):
|
|
parser = build_parser()
|
|
missing = tmp_path / "does_not_exist.pdf"
|
|
args = parser.parse_args(["validate", "--pdf", str(missing)])
|
|
exit_code = args.func(args)
|
|
assert exit_code == 1
|
|
assert "not found" in capsys.readouterr().err
|