This commit is contained in:
32
tests/test_cli.py
Normal file
32
tests/test_cli.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import pytest
|
||||||
|
from click.testing import CliRunner
|
||||||
|
from src.cli import main
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def runner():
|
||||||
|
return CliRunner()
|
||||||
|
|
||||||
|
|
||||||
|
def test_cli_help(runner):
|
||||||
|
result = runner.invoke(main, ['--help'])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert 'LocalAPI Docs' in result.output
|
||||||
|
|
||||||
|
|
||||||
|
def test_cli_serve(runner, tmp_path, sample_spec):
|
||||||
|
result = runner.invoke(main, ['serve', str(sample_spec)])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_cli_generate(runner, tmp_path, sample_spec):
|
||||||
|
output = tmp_path / "output.html"
|
||||||
|
result = runner.invoke(main, ['generate', str(sample_spec), '-o', str(output)])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert output.exists()
|
||||||
|
|
||||||
|
|
||||||
|
def test_cli_validate(runner, sample_spec):
|
||||||
|
result = runner.invoke(main, ['validate', str(sample_spec)])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert 'valid' in result.output.lower()
|
||||||
Reference in New Issue
Block a user