Add tests - part 1
This commit is contained in:
79
tests/test_cli.py
Normal file
79
tests/test_cli.py
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
"""Tests for CLI commands."""
|
||||||
|
|
||||||
|
from click.testing import CliRunner
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from i18n_guardian.cli import main
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def runner():
|
||||||
|
"""Create a Click CLI runner."""
|
||||||
|
return CliRunner()
|
||||||
|
|
||||||
|
|
||||||
|
class TestCLIBasic:
|
||||||
|
"""Basic CLI tests."""
|
||||||
|
|
||||||
|
def test_version(self, runner):
|
||||||
|
"""Test --version option."""
|
||||||
|
result = runner.invoke(main, ["--version"])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert "i18n-guardian" in result.output.lower()
|
||||||
|
|
||||||
|
def test_help(self, runner):
|
||||||
|
"""Test --help option."""
|
||||||
|
result = runner.invoke(main, ["--help"])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert "scan" in result.output.lower()
|
||||||
|
assert "fix" in result.output.lower()
|
||||||
|
assert "init" in result.output.lower()
|
||||||
|
assert "check" in result.output.lower()
|
||||||
|
|
||||||
|
|
||||||
|
class TestScanCommand:
|
||||||
|
"""Tests for scan command."""
|
||||||
|
|
||||||
|
def test_scan_no_path(self, runner):
|
||||||
|
"""Test scan without path."""
|
||||||
|
result = runner.invoke(main, ["scan"])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
def test_scan_with_verbose(self, runner, temp_dir):
|
||||||
|
"""Test scan with verbose flag."""
|
||||||
|
result = runner.invoke(main, ["--verbose", "--path", str(temp_dir), "scan"])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
def test_scan_output_format(self, runner, temp_dir):
|
||||||
|
"""Test scan with different output formats."""
|
||||||
|
for fmt in ["text", "json"]:
|
||||||
|
result = runner.invoke(main, ["--path", str(temp_dir), "scan", "--output", fmt])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
|
||||||
|
class TestFixCommand:
|
||||||
|
"""Tests for fix command."""
|
||||||
|
|
||||||
|
def test_fix_dry_run(self, runner, temp_dir):
|
||||||
|
"""Test fix with dry-run flag."""
|
||||||
|
result = runner.invoke(main, ["--path", str(temp_dir), "fix", "--dry-run"])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
|
||||||
|
class TestInitCommand:
|
||||||
|
"""Tests for init command."""
|
||||||
|
|
||||||
|
def test_init_output(self, runner, temp_dir):
|
||||||
|
"""Test init command output."""
|
||||||
|
output_path = str(temp_dir / ".i18n-guardian.yaml")
|
||||||
|
result = runner.invoke(main, ["init", "--output", output_path])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
|
||||||
|
class TestCheckCommand:
|
||||||
|
"""Tests for check command."""
|
||||||
|
|
||||||
|
def test_check_ci_output(self, runner, temp_dir):
|
||||||
|
"""Test check command with CI options."""
|
||||||
|
result = runner.invoke(main, ["--path", str(temp_dir), "check", "--output", "json"])
|
||||||
|
assert result.exit_code == 0
|
||||||
Reference in New Issue
Block a user