-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathtest_cli.py
More file actions
85 lines (65 loc) · 1.88 KB
/
test_cli.py
File metadata and controls
85 lines (65 loc) · 1.88 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""Testing the Command Line Tool."""
import faulthandler
import json
from pathlib import Path
from polus.images.transforms.images.image_assembler.__main__ import app
from typer.testing import CliRunner
faulthandler.enable()
def test_cli(local_data: tuple[Path, Path, Path, Path]):
"""Test the command line."""
runner = CliRunner()
inp_dir, stitch_dir, out_dir, _ = local_data
result = runner.invoke(
app,
[
"--imgPath",
str(inp_dir),
"--stitchPath",
str(stitch_dir),
"--outDir",
str(out_dir),
],
)
assert result.exit_code == 0
def test_cli_preview(local_data: tuple[Path, Path, Path, Path]):
"""Test the preview option."""
runner = CliRunner()
inp_dir, stitch_dir, out_dir, _ = local_data
result = runner.invoke(
app,
[
"--imgPath",
str(inp_dir),
"--stitchPath",
str(stitch_dir),
"--outDir",
str(out_dir),
"--preview",
],
)
print(result.exception)
print(result.stdout)
assert result.exit_code == 0
with Path.open(out_dir / "preview.json") as file:
plugin_json = json.load(file)
# verify we generate the preview file
result = plugin_json["outputDir"]
assert len(result) == 1
assert Path(result[0]).name == "img_r00(1-2)_c00(1-2).ome.tif"
def test_cli_bad_input(local_data: tuple[Path, Path, Path, Path]):
"""Test bad inputs."""
runner = CliRunner()
inp_dir, stitch_dir, out_dir, _ = local_data
inp_dir = Path("does_not_exists")
result = runner.invoke(
app,
[
"--imgPath",
str(inp_dir),
"--stitchPath",
str(stitch_dir),
"--outDir",
str(out_dir),
],
)
assert result.exc_info[0] is SystemExit