generated from coulomb/repo-seed
merge-duplicates slice and did a first polish
This commit is contained in:
@@ -271,6 +271,7 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
run_detail = client.get(run_path)
|
||||
assert run_detail.status_code == 200
|
||||
assert "Candidate Graph" in run_detail.text
|
||||
assert "ID " in run_detail.text
|
||||
|
||||
approve_response = client.post(
|
||||
f"{run_path}/candidate-graph/approve",
|
||||
@@ -282,6 +283,10 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
assert approved_detail.status_code == 200
|
||||
assert "Approved Ability Map" in approved_detail.text
|
||||
assert "Review UI Repo Repository Usefulness" in approved_detail.text
|
||||
|
||||
search_response = client.get("/ui/search", params={"q": "repository"})
|
||||
assert search_response.status_code == 200
|
||||
assert "UI Repo" in search_response.text
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
@@ -443,3 +448,90 @@ def test_api_relinks_candidate_feature_and_evidence(tmp_path):
|
||||
assert relinked_capabilities[1]["evidence"][0]["id"] == evidence_id
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
def test_api_merges_candidate_capability_feature_and_evidence(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text("# API Merge\n", encoding="utf-8")
|
||||
(source / "requirements.txt").write_text("fastapi\n", encoding="utf-8")
|
||||
(source / "tests").mkdir()
|
||||
(source / "tests" / "test_status.py").write_text(
|
||||
"def test_status(): pass\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(source / "app.py").write_text(
|
||||
"from fastapi import FastAPI\n"
|
||||
"app = FastAPI()\n"
|
||||
'@app.get("/status")\n'
|
||||
"def status():\n"
|
||||
" return {}\n"
|
||||
'@app.get("/ready")\n'
|
||||
"def ready():\n"
|
||||
" return {}\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
def override_settings():
|
||||
return Settings(
|
||||
database_path=str(tmp_path / "api-merge.sqlite3"),
|
||||
checkout_root=str(tmp_path / "api-merge-checkouts"),
|
||||
)
|
||||
|
||||
app.dependency_overrides[get_settings] = override_settings
|
||||
client = TestClient(app)
|
||||
try:
|
||||
repository_response = client.post(
|
||||
"/repos",
|
||||
json={"name": "API Merge", "url": str(source)},
|
||||
)
|
||||
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"]
|
||||
graph_response = client.get(
|
||||
f"/repos/{repository_id}/analysis-runs/{run_id}/candidate-graph"
|
||||
)
|
||||
capabilities = graph_response.json()["abilities"][0]["capabilities"]
|
||||
source_capability = capabilities[0]
|
||||
target_capability = capabilities[1]
|
||||
|
||||
feature_response = client.post(
|
||||
f"/repos/{repository_id}/analysis-runs/{run_id}"
|
||||
f"/candidate-features/{source_capability['features'][1]['id']}/merge",
|
||||
json={
|
||||
"target_feature_id": source_capability["features"][0]["id"],
|
||||
"notes": "Duplicate route",
|
||||
},
|
||||
)
|
||||
assert feature_response.status_code == 200
|
||||
assert (
|
||||
feature_response.json()["abilities"][0]["capabilities"][0]["features"][1][
|
||||
"status"
|
||||
]
|
||||
== "merged"
|
||||
)
|
||||
|
||||
evidence_response = client.post(
|
||||
f"/repos/{repository_id}/analysis-runs/{run_id}"
|
||||
f"/candidate-evidence/{source_capability['evidence'][1]['id']}/merge",
|
||||
json={
|
||||
"target_evidence_id": source_capability["evidence"][0]["id"],
|
||||
"notes": "Duplicate evidence",
|
||||
},
|
||||
)
|
||||
assert evidence_response.status_code == 200
|
||||
|
||||
capability_response = client.post(
|
||||
f"/repos/{repository_id}/analysis-runs/{run_id}"
|
||||
f"/candidate-capabilities/{source_capability['id']}/merge",
|
||||
json={
|
||||
"target_capability_id": target_capability["id"],
|
||||
"notes": "Duplicate capability",
|
||||
},
|
||||
)
|
||||
assert capability_response.status_code == 200
|
||||
capabilities = capability_response.json()["abilities"][0]["capabilities"]
|
||||
assert capabilities[0]["status"] == "merged"
|
||||
assert capabilities[1]["features"]
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
Reference in New Issue
Block a user