Files
code-review-graph/code-review-graph-main/tests/test_project_review.py
T

61 lines
2.2 KiB
Python

"""Tests for the project-review workflow (whole-project / feature scope)."""
from __future__ import annotations
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from fastmcp.prompts.prompt import Message # noqa: E402
from code_review_graph.prompts import project_review_prompt # noqa: E402
def _text(msg: Message) -> str:
return msg.content.text
class TestProjectReviewPromptRendering:
def test_whole_project_renders_full_workflow(self):
text = _text(project_review_prompt()[0])
# Header + shared steps 1-4 must all be present.
assert "## Project Review Workflow" in text
assert "scope=whole-project" in text
assert "1. Call" in text
assert "4. Locate high-risk" in text
# whole-project branch uses all_files=True.
assert "all_files=True" in text
assert "get_knowledge_gaps" in text
def test_feature_renders_feature_branch(self):
text = _text(project_review_prompt(scope="feature", target="checkout")[0])
assert "scope=feature" in text
assert "target=checkout" in text
# Shared steps 1-4 must still be present (no truncation).
assert "4. Locate high-risk" in text
# Feature branch: semantic search + impact radius, not all_files.
assert "semantic_search_nodes" in text
assert "get_impact_radius" in text
assert "all_files=True" not in text
def test_default_scope_is_whole_project(self):
text = _text(project_review_prompt()[0])
assert "scope=whole-project" in text
def test_read_only_present(self):
text = _text(project_review_prompt()[0])
assert "READ-ONLY" in text
def test_both_branches_have_preamble(self):
assert "get_minimal_context" in _text(project_review_prompt()[0])
assert "get_minimal_context" in _text(
project_review_prompt(scope="feature", target="auth")[0]
)
def test_both_branches_end_with_report_step(self):
whole = _text(project_review_prompt()[0])
feat = _text(project_review_prompt(scope="feature", target="x")[0])
assert "generate_report" in whole
assert "generate_report" in feat