Files
local-ai-commit-reviewer/tests/integration/test_review_workflow.py
7000pctAUTO 0090b177d7
Some checks failed
CI / test (push) Has been cancelled
CI / build (push) Has been cancelled
Initial upload: Local AI Commit Reviewer CLI with CI/CD workflow
2026-02-05 06:34:51 +00:00

52 lines
1.8 KiB
Python

import pytest
from pathlib import Path
import subprocess
from fixtures.sample_repo import MockLLMProvider
class TestReviewWorkflow:
def test_review_with_no_staged_changes(self, temp_git_repo, mock_config):
from src.core.review_engine import ReviewEngine
from src.llm import LLMProvider
engine = ReviewEngine(config=mock_config, llm_provider=MockLLMProvider())
engine.set_repo(temp_git_repo)
result = engine.review_staged_changes([])
assert result.error == "No staged changes found"
def test_review_with_staged_file(self, temp_git_repo, sample_python_file, mock_config):
from src.core.review_engine import ReviewEngine
from src.git import get_staged_changes
subprocess.run(["git", "add", "test.py"], cwd=temp_git_repo, capture_output=True)
changes = get_staged_changes(temp_git_repo)
engine = ReviewEngine(config=mock_config, llm_provider=MockLLMProvider())
engine.set_repo(temp_git_repo)
result = engine.review_staged_changes(changes)
assert result.review_mode == "balanced"
assert result.error is None or len(result.issues) >= 0
class TestHookInstallation:
def test_install_hook(self, temp_git_repo):
from src.hooks import install_pre_commit_hook
result = install_pre_commit_hook(temp_git_repo)
assert result is True
hook_path = temp_git_repo / ".git" / "hooks" / "pre-commit"
assert hook_path.exists()
content = hook_path.read_text()
assert "aicr" in content or "review" in content
def test_check_hook_installed(self, temp_git_repo):
from src.hooks import install_pre_commit_hook, check_hook_installed
assert check_hook_installed(temp_git_repo) is False
install_pre_commit_hook(temp_git_repo)
assert check_hook_installed(temp_git_repo) is True