generated from coulomb/repo-seed
Milestone 3: candidate graph generation
This commit is contained in:
45
tests/test_candidate_graph.py
Normal file
45
tests/test_candidate_graph.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from repo_registry.candidate_graph.generator import CandidateGraphGenerator
|
||||
from repo_registry.core.models import ObservedFact, Repository
|
||||
|
||||
|
||||
def fact(id, kind, name, path="", value=""):
|
||||
return ObservedFact(
|
||||
id=id,
|
||||
repository_id=1,
|
||||
analysis_run_id=1,
|
||||
snapshot_id=1,
|
||||
kind=kind,
|
||||
path=path,
|
||||
name=name,
|
||||
value=value,
|
||||
metadata={},
|
||||
)
|
||||
|
||||
|
||||
def test_candidate_generator_builds_review_seed_from_observed_facts():
|
||||
repository = Repository(
|
||||
id=1,
|
||||
name="MailRouter",
|
||||
url="/tmp/mail-router",
|
||||
description=None,
|
||||
branch="main",
|
||||
status="analyzed",
|
||||
)
|
||||
facts = [
|
||||
fact(1, "documentation", "README", "README.md"),
|
||||
fact(2, "interface", "python route decorator", "app.py", '@app.post("/classify")'),
|
||||
fact(3, "test", "test_app.py", "tests/test_app.py"),
|
||||
fact(4, "framework", "FastAPI", "requirements.txt"),
|
||||
]
|
||||
|
||||
graph = CandidateGraphGenerator().generate(repository, facts)
|
||||
|
||||
assert len(graph) == 1
|
||||
ability = graph[0]
|
||||
assert ability.name == "Review MailRouter Repository Usefulness"
|
||||
assert ability.source_refs[0].path == "README.md"
|
||||
interface_capability = ability.capabilities[0]
|
||||
assert interface_capability.name == "Expose Repository Interface"
|
||||
assert interface_capability.features[0].type == "API"
|
||||
assert interface_capability.features[0].location == "app.py"
|
||||
assert interface_capability.evidence[0].strength == "strong"
|
||||
Reference in New Issue
Block a user