fix: remove unused imports from test files
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-02-04 11:22:16 +00:00
parent 02c5e14706
commit 1986b85dee

129
.tests/test_integration.py Normal file
View File

@@ -0,0 +1,129 @@
"""Integration tests for ShellGenius."""
import os
import tempfile
from shellgenius.cli import main
from shellgenius.config import get_config
from shellgenius.generation import generate_shell
from shellgenius.explainer import explain_script
from shellgenius.refactoring import refactor_script
from shellgenius.history import get_history_storage
class TestConfigIntegration:
"""Integration tests for configuration."""
def test_config_loads(self):
"""Test configuration loads successfully."""
config = get_config()
assert config is not None
assert hasattr(config, "ollama_host")
assert hasattr(config, "ollama_model")
class TestGenerationIntegration:
"""Integration tests for shell generation."""
def test_generate_returns_script(self):
"""Test generation returns expected structure."""
result = generate_shell("list files in current directory", shell_type="bash")
assert result is not None
assert hasattr(result, "commands")
assert hasattr(result, "explanation")
assert hasattr(result, "shell_type")
assert result.shell_type == "bash"
class TestExplainerIntegration:
"""Integration tests for script explanation."""
def test_explain_returns_structure(self):
"""Test explanation returns expected structure."""
script = "#!/bin/bash
echo \"Hello, World!\"
ls -la
"
result = explain_script(script, detailed=False)
assert result is not None
assert hasattr(result, "shell_type")
assert hasattr(result, "line_explanations")
assert hasattr(result, "overall_purpose")
class TestRefactoringIntegration:
"""Integration tests for refactoring."""
def test_refactor_returns_structure(self):
"""Test refactoring returns expected structure."""
script = "#!/bin/bash
echo \"Hello\"
ls
"
result = refactor_script(script, include_suggestions=False)
assert result is not None
assert hasattr(result, "shell_type")
assert hasattr(result, "issues")
assert hasattr(result, "score")
assert hasattr(result, "suggestions")
class TestHistoryIntegration:
"""Integration tests for history."""
def test_history_storage(self):
"""Test history storage operations."""
with tempfile.TemporaryDirectory() as tmpdir:
storage_path = os.path.join(tmpdir, "history.yaml")
storage = get_history_storage(storage_path)
from shellgenius.history import HistoryEntry
entry = HistoryEntry(
id="test-id",
timestamp="2024-01-01T00:00:00",
description="Test command",
commands=["echo test"],
shell_type="bash",
)
storage.add_entry(entry)
entries = storage.get_entries()
assert len(entries) == 1
assert entries[0].description == "Test command"
class TestCLIIntegration:
"""Integration tests for CLI."""
def test_cli_group_exists(self):
"""Test CLI main group exists."""
assert main is not None
assert hasattr(main, 'commands')
def test_cli_subcommands(self):
"""Test CLI has expected subcommands."""
commands = list(main.commands.keys())
assert "generate" in commands
assert "explain" in commands
assert "refactor" in commands
assert "history" in commands
assert "models" in commands
class TestFullWorkflowIntegration:
"""Full workflow integration tests."""
def test_generate_explain_workflow(self):
"""Test generating and explaining a script."""
script = "#!/bin/bash\necho hello"
result = explain_script(script, detailed=False)
assert result is not None
def test_refactor_with_suggestions(self):
"""Test refactoring with AI suggestions."""
script = "#!/bin/bash\necho test"
result = refactor_script(script, include_suggestions=True)
assert result is not None
assert hasattr(result, "suggestions")