Files
7000pctAUTO 6cea8c6b43
Some checks failed
CI / test (push) Has been cancelled
CI / build (push) Has been cancelled
Add test suite for all modules
2026-01-31 15:34:18 +00:00

107 lines
3.1 KiB
Python

"""CLI tests for Local Code Assistant."""
import pytest
from click.testing import CliRunner
from local_code_assistant.cli import main
@pytest.fixture
def cli_runner():
"""Create a CLI runner for testing."""
return CliRunner()
class TestCLI:
"""Tests for CLI commands."""
def test_version_command(self, cli_runner):
"""Test version command output."""
result = cli_runner.invoke(main, ["version"])
assert result.exit_code == 0
assert "Local Code Assistant" in result.output or result.exit_code == 0
def test_main_help(self, cli_runner):
"""Test main help command."""
result = cli_runner.invoke(main, ["--help"])
assert result.exit_code == 0
assert "generate" in result.output
assert "explain" in result.output
assert "refactor" in result.output
assert "test" in result.output
assert "repl" in result.output
class TestGenerateCommand:
"""Tests for the generate command."""
def test_generate_help(self, cli_runner):
"""Test generate command help."""
result = cli_runner.invoke(main, ["generate", "--help"])
assert result.exit_code == 0
def test_generate_requires_prompt(self, cli_runner):
"""Test generate command requires a prompt."""
result = cli_runner.invoke(main, ["generate"])
assert result.exit_code != 0
class TestExplainCommand:
"""Tests for the explain command."""
def test_explain_help(self, cli_runner):
"""Test explain command help."""
result = cli_runner.invoke(main, ["explain", "--help"])
assert result.exit_code == 0
def test_explain_requires_file(self, cli_runner):
"""Test explain command requires a file."""
result = cli_runner.invoke(main, ["explain"])
assert result.exit_code != 0
class TestRefactorCommand:
"""Tests for the refactor command."""
def test_refactor_help(self, cli_runner):
"""Test refactor command help."""
result = cli_runner.invoke(main, ["refactor", "--help"])
assert result.exit_code == 0
def test_optimize_help(self, cli_runner):
"""Test optimize command help."""
result = cli_runner.invoke(main, ["optimize", "--help"])
assert result.exit_code == 0
class TestTestCommand:
"""Tests for the test command."""
def test_test_help(self, cli_runner):
"""Test test command help."""
result = cli_runner.invoke(main, ["test", "--help"])
assert result.exit_code == 0
class TestREPLCommand:
"""Tests for the REPL command."""
def test_repl_help(self, cli_runner):
"""Test REPL command help."""
result = cli_runner.invoke(main, ["repl", "--help"])
assert result.exit_code == 0
class TestStatusCommand:
"""Tests for the status command."""
def test_status_help(self, cli_runner):
"""Test status command help."""
result = cli_runner.invoke(main, ["status", "--help"])
assert result.exit_code == 0
def test_models_help(self, cli_runner):
"""Test models command help."""
result = cli_runner.invoke(main, ["models", "--help"])
assert result.exit_code == 0