generated from coulomb/repo-seed
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
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"
|