File size: 901 Bytes
f340984
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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")