Skip to content

Commit

Permalink
chg: fully cover the inscript client with unittests.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertWeichselbraun committed Feb 17, 2024
1 parent 80c8dd1 commit 35626dd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,24 @@ def test_help(monkeypatch, capsys):
captured = capsys.readouterr().out
assert captured.startswith("Inscript HTML to text conversion")
assert "Inscript comes with ABSOLUTELY NO WARRANTY." in captured


def test_missing_input_file(monkeypatch, capsys):
monkeypatch.setattr("sys.argv", ["inscript", "test.html"])
with pytest.raises(SystemExit) as exit_info:
cli()

captured = capsys.readouterr()
assert exit_info.value.code == -1
assert captured.out.strip().startswith("ERROR: Cannot open input file")


def test_missing_annotation_file(monkeypatch, capsys):
monkeypatch.setattr("sys.argv", ["inscript", "--annotation-rules", "rules.json"])
monkeypatch.setattr("sys.stdin", StringIO(INPUT_DATA))
with pytest.raises(SystemExit) as exit_info:
cli()

captured = capsys.readouterr()
assert exit_info.value.code == -1
assert captured.out.strip().startswith("ERROR: Cannot open annotation rule file")

0 comments on commit 35626dd

Please sign in to comment.