Files
code-review-graph/tests/test_unified_review.py
T
dev 84ae9b817e feat: add unified-review workflow (scoring tools + skill)
Adds the unified-review integration that fuses CRG graph context with the
ai-code-review scoring methodology and gstack-review fix-first workflow:

- scoring.py: objective Layer-2 metrics (sql_risk, exception_coverage,
  redundancy_rate, high_risk_density, vulnerability_risk) with
  good/warn/fail grades, plus dedupe_findings (fingerprint merge,
  multi-source confidence boost, PR quality score) and report data builder
- tools/scoring_tools.py + main.py: three new MCP tools
  (score_review_tool, dedupe_findings_tool, generate_report_tool)
- assets/report-template.html: self-contained HTML report template
- skills.py + skills/unified-review/: new read-only unified-review skill
  with language/manual-review/specialist checklists
- docs and CHANGELOG updated; tests added (test_scoring, test_report,
  test_unified_review) and test_skills updated for 5 skills
2026-08-05 13:31:55 +08:00

68 lines
2.1 KiB
Python

"""Tests for unified-review MCP tool wiring (registration + docs sections)."""
from __future__ import annotations
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from code_review_graph.tools import ( # noqa: E402
dedupe_findings_func,
generate_report_func,
score_review_func,
)
from code_review_graph.tools.docs import get_docs_section # noqa: E402
class TestToolRegistration:
def test_scoring_funcs_exported(self):
assert callable(score_review_func)
assert callable(dedupe_findings_func)
assert callable(generate_report_func)
def test_mcp_tools_exposed(self):
import code_review_graph.main as m
for name in (
"score_review_tool",
"dedupe_findings_tool",
"generate_report_tool",
):
assert hasattr(m, name), f"{name} not exposed by main module"
class TestDocsSections:
def test_unified_review_section(self):
result = get_docs_section("unified-review")
assert result["status"] == "ok"
assert "score_review_tool" in result["content"]
def test_score_review_section(self):
result = get_docs_section("score-review")
assert result["status"] == "ok"
assert "dedupe_findings_tool" in result["content"]
def test_unknown_section(self):
result = get_docs_section("does-not-exist")
assert result["status"] == "not_found"
assert "unified-review" in result["error"]
class TestGenerateSkills:
def test_unified_review_generated(self, tmp_path):
from code_review_graph.skills import generate_skills
skills_dir = generate_skills(tmp_path)
skill_file = skills_dir / "unified-review" / "SKILL.md"
assert skill_file.is_file()
content = skill_file.read_text(encoding="utf-8")
assert "score_review_tool" in content
assert "get_minimal_context" in content
assert "detail_level" in content
def test_uninstall_knows_unified_review(self):
from code_review_graph.uninstall import _generated_skill_slugs
assert "unified-review" in _generated_skill_slugs()