Skip to content

Commit

Permalink
chore(tests): Implement some initial CLI tests
Browse files Browse the repository at this point in the history
See also #7, #8
  • Loading branch information
alexpovel committed Jul 26, 2022
1 parent 6fd7baa commit b303b9a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

TESTS_DIR = Path(__file__).parent
DATA_DIR = TESTS_DIR / "data"
RESUMES_DIR = DATA_DIR / "resumes"
RESUMES = list(RESUMES_DIR.iterdir())
40 changes: 40 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pytest
from typer.testing import CliRunner

from ancv.__main__ import app
from tests import RESUMES

RUNNER = CliRunner()


def test_help_exists():
result = RUNNER.invoke(app, ["--help"])
assert result.exit_code == 0


def test_serve_exists():
result = RUNNER.invoke(app, ["serve"])
assert result.exit_code == 0


def test_serve_file_exists():
result = RUNNER.invoke(app, ["serve", "file", "--help"])
assert result.exit_code == 0


def test_serve_api_exists():
result = RUNNER.invoke(app, ["serve", "api", "--help"])
assert result.exit_code == 0


@pytest.mark.parametrize("filename", RESUMES)
# All resumes as a single fixture wouldn't be too bad either but doesn't work:
# https://stackoverflow.com/q/56672179/11477374
class TestCli:
def test_validate(self, filename):
result = RUNNER.invoke(app, ["validate", str(filename)])
assert result.exit_code == 0

def test_render(self, filename):
result = RUNNER.invoke(app, ["render", str(filename)])
assert result.exit_code == 0

0 comments on commit b303b9a

Please sign in to comment.