This repository has been archived on 2024-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
Colligere/tests/test_cli.py

38 lines
977 B
Python

from colligere.cli import main
from pathlib import Path
ASSETS = Path(__file__).parent.parent / "assets"
JSONL = ASSETS / "test.jsonl"
def assert_out(capsys, msg, *args):
args = tuple(map(lambda a: str(a), args))
try:
main(args)
except SystemExit:
pass
assert msg in capsys.readouterr().out
def test_helps(capsys):
cmds = [
["-h"],
["analize", "-h"],
]
for args in cmds:
assert_out(capsys, "usage:", *args)
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)