diff --git a/tests/integration/test_cli.py b/tests/integration/test_cli.py new file mode 100644 index 0000000..7fe6ee7 --- /dev/null +++ b/tests/integration/test_cli.py @@ -0,0 +1,59 @@ +"""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() + + @pytest.fixture + def sample_spec_path(self): + """Path to sample spec file.""" + return "examples/petstore.yaml" + + 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()