47 lines
1.8 KiB
Python
47 lines
1.8 KiB
Python
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 # noqa: PLC0415
|
|
|
|
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, mock_config, request):
|
|
from src.core.review_engine import ReviewEngine # noqa: PLC0415
|
|
from src.git import get_staged_changes # noqa: PLC0415
|
|
|
|
request.getfixturevalue("sample_python_file")
|
|
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 # noqa: PLC0415
|
|
|
|
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 check_hook_installed, install_pre_commit_hook # noqa: PLC0415
|
|
|
|
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
|