Files
mockapi/tests/integration/test_cli.py
7000pctAUTO dc5d0c4942
Some checks failed
CI / test (push) Has been cancelled
Fix test_cli.py to use sample_spec_path fixture
2026-03-22 22:17:28 +00:00

54 lines
1.9 KiB
Python

"""Integration tests for CLI."""
import os
import pytest
from click.testing import CliRunner
from mockapi.cli.main import cli
class TestCLIIntegration:
"""Integration tests for CLI commands."""
@pytest.fixture
def runner(self):
"""Create CLI runner."""
return CliRunner()
def test_validate_command(self, runner, sample_spec_path):
"""Test validate command."""
result = runner.invoke(cli, ["validate", sample_spec_path])
assert result.exit_code == 0
assert "valid" in result.output.lower() or "paths" in result.output.lower()
def test_validate_nonexistent_file(self, runner):
"""Test validate command with non-existent file."""
result = runner.invoke(cli, ["validate", "nonexistent.yaml"])
assert result.exit_code != 0
def test_generate_command(self, runner, sample_spec_path):
"""Test generate command."""
result = runner.invoke(cli, ["generate", sample_spec_path])
assert result.exit_code == 0
assert "users" in result.output.lower() or "endpoints" in result.output.lower()
def test_show_config_command(self, runner):
"""Test show-config command."""
result = runner.invoke(cli, ["show-config"])
assert result.exit_code == 0
assert "port" in result.output.lower()
assert "host" in result.output.lower()
def test_cli_version(self, runner):
"""Test CLI version flag."""
result = runner.invoke(cli, ["--version"])
assert result.exit_code == 0
assert "mockapi" in result.output.lower() or "0.1" in result.output
def test_cli_help(self, runner):
"""Test CLI help."""
result = runner.invoke(cli, ["--help"])
assert result.exit_code == 0
assert "validate" in result.output.lower()
assert "start" in result.output.lower()
assert "generate" in result.output.lower()