generated from coulomb/repo-seed
baseline repo characteristics no longer crowd the candidate graph
This commit is contained in:
@@ -1,9 +1,47 @@
|
||||
import json
|
||||
import sqlite3
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from repo_registry.web_api import app as app_module
|
||||
from repo_registry.web_api.app import Settings, app, get_service, get_settings
|
||||
|
||||
|
||||
def add_candidate_capability(database_path, repository_id, analysis_run_id, name):
|
||||
with sqlite3.connect(database_path) as connection:
|
||||
ability_id = connection.execute(
|
||||
"""
|
||||
SELECT id FROM candidate_abilities
|
||||
WHERE repository_id = ? AND analysis_run_id = ?
|
||||
ORDER BY id
|
||||
LIMIT 1
|
||||
""",
|
||||
(repository_id, analysis_run_id),
|
||||
).fetchone()[0]
|
||||
cursor = connection.execute(
|
||||
"""
|
||||
INSERT INTO candidate_capabilities
|
||||
(repository_id, analysis_run_id, ability_id, name, description,
|
||||
inputs, outputs, primary_class, attributes, confidence, source_refs)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
repository_id,
|
||||
analysis_run_id,
|
||||
ability_id,
|
||||
name,
|
||||
"Review target capability inserted for API review workflow tests.",
|
||||
"[]",
|
||||
"[]",
|
||||
"test-capability",
|
||||
json.dumps(["test-review-target"]),
|
||||
0.5,
|
||||
"[]",
|
||||
),
|
||||
)
|
||||
return int(cursor.lastrowid)
|
||||
|
||||
|
||||
def test_openapi_groups_agent_facing_endpoints():
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -875,10 +913,11 @@ def test_api_analysis_run_loop(tmp_path):
|
||||
'{"dependencies":{"react":"latest","vite":"latest"}}',
|
||||
encoding="utf-8",
|
||||
)
|
||||
database_path = str(tmp_path / "api-analysis.sqlite3")
|
||||
|
||||
def override_settings():
|
||||
return Settings(
|
||||
database_path=str(tmp_path / "api-analysis.sqlite3"),
|
||||
database_path=database_path,
|
||||
checkout_root=str(tmp_path / "api-checkouts"),
|
||||
)
|
||||
|
||||
@@ -903,6 +942,12 @@ def test_api_analysis_run_loop(tmp_path):
|
||||
assert get_run_response.status_code == 200
|
||||
assert get_run_response.json()["id"] == run["analysis_run"]["id"]
|
||||
|
||||
add_candidate_capability(
|
||||
database_path,
|
||||
repository_id,
|
||||
run["analysis_run"]["id"],
|
||||
"Describe Frontend Stack",
|
||||
)
|
||||
candidate_response = client.get(
|
||||
f"/repos/{repository_id}/analysis-runs/"
|
||||
f"{run['analysis_run']['id']}/candidate-graph"
|
||||
@@ -954,6 +999,12 @@ def test_api_analysis_run_loop(tmp_path):
|
||||
run_response = client.post(f"/repos/{repository_id}/analysis-runs", json={})
|
||||
assert run_response.status_code == 201
|
||||
run = run_response.json()
|
||||
add_candidate_capability(
|
||||
database_path,
|
||||
repository_id,
|
||||
run["analysis_run"]["id"],
|
||||
"Describe Frontend Stack",
|
||||
)
|
||||
candidate_response = client.get(
|
||||
f"/repos/{repository_id}/analysis-runs/"
|
||||
f"{run['analysis_run']['id']}/candidate-graph"
|
||||
@@ -1358,7 +1409,7 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
assert "Analysis completed with reviewable results." in run_detail.text
|
||||
assert "Candidate Graph" in run_detail.text
|
||||
assert "1 abilities" in run_detail.text
|
||||
assert "2 capabilities" in run_detail.text
|
||||
assert "1 capabilities" in run_detail.text
|
||||
assert "2 features" in run_detail.text
|
||||
assert "8 facts" in run_detail.text
|
||||
assert "Content Chunks" in run_detail.text
|
||||
@@ -1426,11 +1477,11 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
assert "1 scope" in approved_detail.text
|
||||
assert "supports" in approved_detail.text
|
||||
assert "1 abilities" in approved_detail.text
|
||||
assert "2 capabilities" in approved_detail.text
|
||||
assert "1 capabilities" in approved_detail.text
|
||||
assert "2 features" in approved_detail.text
|
||||
assert "Latest Candidate Graph" in approved_detail.text
|
||||
assert "1 candidate abilities" in approved_detail.text
|
||||
assert "2 candidate capabilities" in approved_detail.text
|
||||
assert "1 candidate capabilities" in approved_detail.text
|
||||
assert "2 candidate features" in approved_detail.text
|
||||
assert "8 candidate facts" in approved_detail.text
|
||||
assert "Use Approved Registry" in approved_detail.text
|
||||
@@ -1801,6 +1852,44 @@ def test_ui_analysis_run_diagnostics_explain_failures_and_empty_results(tmp_path
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
def test_ui_analysis_run_diagnostics_warn_when_only_baseline_context_exists(tmp_path):
|
||||
source = tmp_path / "dependency-only-ui"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text("# Dependency Only\nUses libraries.\n", encoding="utf-8")
|
||||
(source / "requirements.txt").write_text("fastapi\npytest\n", encoding="utf-8")
|
||||
|
||||
def override_settings():
|
||||
return Settings(
|
||||
database_path=str(tmp_path / "ui-baseline-diagnostics.sqlite3"),
|
||||
checkout_root=str(tmp_path / "ui-baseline-diagnostics-checkouts"),
|
||||
)
|
||||
|
||||
app.dependency_overrides[get_settings] = override_settings
|
||||
client = TestClient(app)
|
||||
try:
|
||||
repository = client.post(
|
||||
"/repos",
|
||||
json={
|
||||
"url": str(source),
|
||||
"name": "Dependency Only UI",
|
||||
"description": "Used for baseline diagnostics.",
|
||||
},
|
||||
).json()
|
||||
run = client.post(
|
||||
f"/ui/repos/{repository['id']}/analysis-runs",
|
||||
data={"source_path": "", "use_llm_assistance": ""},
|
||||
follow_redirects=False,
|
||||
)
|
||||
|
||||
detail = client.get(run.headers["location"])
|
||||
|
||||
assert detail.status_code == 200
|
||||
assert "No domain capabilities were produced." in detail.text
|
||||
assert "only baseline context or weak documentation was available" in detail.text
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
def test_ui_register_and_explore_lands_on_analysis_result(tmp_path):
|
||||
source = tmp_path / "explore-repo"
|
||||
source.mkdir()
|
||||
@@ -2550,9 +2639,11 @@ def test_api_relinks_candidate_feature_and_evidence(tmp_path):
|
||||
" return {}\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
database_path = str(tmp_path / "api-relink.sqlite3")
|
||||
|
||||
def override_settings():
|
||||
return Settings(
|
||||
database_path=str(tmp_path / "api-relink.sqlite3"),
|
||||
database_path=database_path,
|
||||
checkout_root=str(tmp_path / "api-relink-checkouts"),
|
||||
)
|
||||
|
||||
@@ -2566,6 +2657,12 @@ def test_api_relinks_candidate_feature_and_evidence(tmp_path):
|
||||
repository_id = repository_response.json()["id"]
|
||||
run_response = client.post(f"/repos/{repository_id}/analysis-runs", json={})
|
||||
run_id = run_response.json()["analysis_run"]["id"]
|
||||
add_candidate_capability(
|
||||
database_path,
|
||||
repository_id,
|
||||
run_id,
|
||||
"Review Target Capability",
|
||||
)
|
||||
graph_response = client.get(
|
||||
f"/repos/{repository_id}/analysis-runs/{run_id}/candidate-graph"
|
||||
)
|
||||
@@ -2631,10 +2728,11 @@ def test_api_merges_candidate_capability_feature_and_evidence(tmp_path):
|
||||
" click.echo('ok')\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
database_path = str(tmp_path / "api-merge.sqlite3")
|
||||
|
||||
def override_settings():
|
||||
return Settings(
|
||||
database_path=str(tmp_path / "api-merge.sqlite3"),
|
||||
database_path=database_path,
|
||||
checkout_root=str(tmp_path / "api-merge-checkouts"),
|
||||
)
|
||||
|
||||
@@ -2648,6 +2746,12 @@ def test_api_merges_candidate_capability_feature_and_evidence(tmp_path):
|
||||
repository_id = repository_response.json()["id"]
|
||||
run_response = client.post(f"/repos/{repository_id}/analysis-runs", json={})
|
||||
run_id = run_response.json()["analysis_run"]["id"]
|
||||
add_candidate_capability(
|
||||
database_path,
|
||||
repository_id,
|
||||
run_id,
|
||||
"Review Target Capability",
|
||||
)
|
||||
graph_response = client.get(
|
||||
f"/repos/{repository_id}/analysis-runs/{run_id}/candidate-graph"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user