This commit is contained in:
82
shellhist/tests/test_cli.py
Normal file
82
shellhist/tests/test_cli.py
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
"""Tests for CLI commands."""
|
||||||
|
|
||||||
|
from click.testing import CliRunner
|
||||||
|
|
||||||
|
from shellhist.cli import main
|
||||||
|
|
||||||
|
|
||||||
|
class TestCLI:
|
||||||
|
"""Test CLI main entry point."""
|
||||||
|
|
||||||
|
def test_version(self):
|
||||||
|
"""Test version option."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(main, ["--version"])
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert "shellhist" in result.output.lower()
|
||||||
|
|
||||||
|
def test_help(self):
|
||||||
|
"""Test help option."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(main, ["--help"])
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert "search" in result.output
|
||||||
|
assert "patterns" in result.output
|
||||||
|
|
||||||
|
def test_search_command_exists(self):
|
||||||
|
"""Test search subcommand exists."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(main, ["search", "--help"])
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
def test_patterns_command_exists(self):
|
||||||
|
"""Test patterns subcommand exists."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(main, ["patterns", "--help"])
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
def test_suggest_aliases_command_exists(self):
|
||||||
|
"""Test suggest-aliases subcommand exists."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(main, ["suggest-aliases", "--help"])
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
def test_analyze_time_command_exists(self):
|
||||||
|
"""Test analyze-time subcommand exists."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(main, ["analyze-time", "--help"])
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
def test_export_script_command_exists(self):
|
||||||
|
"""Test export-script subcommand exists."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(main, ["export-script", "--help"])
|
||||||
|
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
def test_search_with_missing_history(self):
|
||||||
|
"""Test search with non-existent history file."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(
|
||||||
|
main,
|
||||||
|
["search", "test", "--history", "/nonexistent/file"]
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result.exit_code != 0
|
||||||
|
assert "not found" in result.output.lower() or "error" in result.output.lower()
|
||||||
|
|
||||||
|
def test_patterns_with_missing_history(self):
|
||||||
|
"""Test patterns with non-existent history file."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(
|
||||||
|
main,
|
||||||
|
["patterns", "--history", "/nonexistent/file"]
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result.exit_code != 0
|
||||||
Reference in New Issue
Block a user