2023-12-15 17:11:25 -06:00
|
|
|
from colligere.cli import main
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
ASSETS = Path(__file__).parent.parent / "assets"
|
|
|
|
JSONL = ASSETS / "test.jsonl"
|
2023-12-08 15:41:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
def assert_out(capsys, msg, *args):
|
2023-12-15 17:11:25 -06:00
|
|
|
args = tuple(map(lambda a: str(a), args))
|
2023-12-08 15:41:43 -06:00
|
|
|
try:
|
2023-12-15 17:11:25 -06:00
|
|
|
main(args)
|
2023-12-08 15:41:43 -06:00
|
|
|
except SystemExit:
|
|
|
|
pass
|
2023-12-15 17:11:25 -06:00
|
|
|
assert msg in capsys.readouterr().out
|
2023-12-08 15:41:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
def test_helps(capsys):
|
2023-12-15 17:11:25 -06:00
|
|
|
cmds = [
|
|
|
|
["-h"],
|
|
|
|
["analize", "-h"],
|
|
|
|
]
|
|
|
|
for args in cmds:
|
2023-12-08 15:41:43 -06:00
|
|
|
assert_out(capsys, "usage:", *args)
|
2023-12-15 17:11:25 -06:00
|
|
|
|
|
|
|
|
|
|
|
def test_analize(capsys):
|
|
|
|
cmds = [
|
|
|
|
["analize", "-q", "-d", ASSETS, JSONL],
|
|
|
|
["analize", "-d", ASSETS, JSONL],
|
|
|
|
["analize", "-i", 5, "-d", ASSETS, JSONL],
|
|
|
|
["analize", "-k", "foo", "-d", ASSETS, JSONL],
|
|
|
|
["analize", "-k", "foo", "-k", "bar", "-d", ASSETS, JSONL],
|
|
|
|
["analize", "-k", "foo", "-ky", "bar", "-d", ASSETS, JSONL],
|
|
|
|
]
|
|
|
|
for args in cmds:
|
|
|
|
msg = "Total time:" if "-q" not in args else ""
|
|
|
|
assert_out(capsys, msg, *args)
|