| import json | |
| from pathlib import Path | |
| from unlimited_ocr_rdna4.cli import run | |
| from unlimited_ocr_rdna4.infer import default_output_path | |
| def test_prepare_dry_run_json_after_subcommand(capsys, tmp_path) -> None: | |
| code = run( | |
| [ | |
| "prepare", | |
| "--model-dir", | |
| str(tmp_path / "model"), | |
| "--cache-dir", | |
| str(tmp_path / "cache"), | |
| "--dry-run", | |
| "--json", | |
| ] | |
| ) | |
| assert code == 0 | |
| payload = json.loads(capsys.readouterr().out) | |
| assert payload["schema_version"] == 1 | |
| assert payload["status"] == "dry-run" | |
| assert payload["prepared"] is False | |
| def test_no_command_returns_usage_error(capsys) -> None: | |
| assert run([]) == 2 | |
| assert "usage:" in capsys.readouterr().err | |
| def test_default_output_path() -> None: | |
| assert default_output_path(Path("invoice.pdf")) == Path("invoice.pdf.ocr.md") | |