Files
repo-scoping/tests/test_scanner_coevolution.py
2026-04-29 01:19:59 +02:00

66 lines
2.2 KiB
Python

import json
from pathlib import Path
from repo_registry.core.service import RegistryService
from repo_registry.repo_ingestion.git import GitIngestionService
from repo_registry.storage.sqlite import RegistryStore
def test_llm_connect_provider_expectations_are_detected_without_llm(tmp_path):
expectation_path = (
Path(__file__).parent
/ "expectations"
/ "llm_connect_provider_expectations.json"
)
expectations = json.loads(expectation_path.read_text(encoding="utf-8"))
source = tmp_path / expectations["repository"]
source.mkdir()
(source / "README.md").write_text(
"# LLM Connect\nSupports OpenRouter and Claude fallback for hard prompts.\n",
encoding="utf-8",
)
(source / ".env.example").write_text(
"OPENROUTER_API_KEY=\nANTHROPIC_API_KEY=\n",
encoding="utf-8",
)
(source / "providers.py").write_text(
"provider_registry = {'openrouter': object(), 'claude': object()}\n"
"fallback_provider = 'claude'\n",
encoding="utf-8",
)
store = RegistryStore(tmp_path / "registry.sqlite3")
store.initialize()
service = RegistryService(
store,
ingestion=GitIngestionService(tmp_path / "checkouts"),
)
repository = service.register_repository(name="LLM Connect", url=str(source))
summary = service.analyze_repository(
repository.id,
use_llm_assistance=False,
)
facts = service.list_observed_facts(repository.id, summary.analysis_run.id)
graph = service.candidate_graph(repository.id, summary.analysis_run.id)
fact_pairs = {(fact.kind, fact.name) for fact in facts}
for expected in expectations["expected_facts"]:
assert (expected["kind"], expected["name"]) in fact_pairs
candidate_names = {
graph.abilities[0].name,
*[
capability.name
for ability in graph.abilities
for capability in ability.capabilities
],
*[
feature.name
for ability in graph.abilities
for capability in ability.capabilities
for feature in capability.features
],
}
for expected in expectations["expected_candidates"]:
assert expected in candidate_names