generated from coulomb/repo-seed
UI can now build an approved profile by hand
This commit is contained in:
@@ -66,13 +66,63 @@ def test_api_manual_registry_loop(tmp_path):
|
||||
},
|
||||
)
|
||||
assert feature_response.status_code == 201
|
||||
feature_id = feature_response.json()["id"]
|
||||
|
||||
evidence_response = client.post(
|
||||
f"/repos/{repository_id}/evidence",
|
||||
json={
|
||||
"capability_id": capability_id,
|
||||
"type": "unit_test",
|
||||
"reference": "tests/test_email_classification.py",
|
||||
},
|
||||
)
|
||||
assert evidence_response.status_code == 201
|
||||
evidence_id = evidence_response.json()["id"]
|
||||
|
||||
ability_update_response = client.patch(
|
||||
f"/repos/{repository_id}/abilities/{ability_id}",
|
||||
json={"name": "Business Email Routing Updated"},
|
||||
)
|
||||
assert ability_update_response.status_code == 200
|
||||
assert ability_update_response.json()["abilities"][0]["name"] == (
|
||||
"Business Email Routing Updated"
|
||||
)
|
||||
|
||||
capability_update_response = client.patch(
|
||||
f"/repos/{repository_id}/capabilities/{capability_id}",
|
||||
json={"name": "Classify Incoming Email Updated"},
|
||||
)
|
||||
assert capability_update_response.status_code == 200
|
||||
assert capability_update_response.json()["abilities"][0]["capabilities"][0][
|
||||
"name"
|
||||
] == "Classify Incoming Email Updated"
|
||||
|
||||
feature_update_response = client.patch(
|
||||
f"/repos/{repository_id}/features/{feature_id}",
|
||||
json={"location": "src/routes/updated.py"},
|
||||
)
|
||||
assert feature_update_response.status_code == 200
|
||||
evidence_update_response = client.patch(
|
||||
f"/repos/{repository_id}/evidence/{evidence_id}",
|
||||
json={"strength": "strong"},
|
||||
)
|
||||
assert evidence_update_response.status_code == 200
|
||||
|
||||
map_response = client.get(f"/repos/{repository_id}/ability-map")
|
||||
assert map_response.status_code == 200
|
||||
ability_map = map_response.json()
|
||||
assert ability_map["repository"]["name"] == "MailRouter Updated"
|
||||
assert ability_map["abilities"][0]["capabilities"][0]["name"] == (
|
||||
"Classify Incoming Email"
|
||||
"Classify Incoming Email Updated"
|
||||
)
|
||||
|
||||
assert (
|
||||
client.delete(f"/repos/{repository_id}/features/{feature_id}").status_code
|
||||
== 200
|
||||
)
|
||||
assert (
|
||||
client.delete(f"/repos/{repository_id}/evidence/{evidence_id}").status_code
|
||||
== 200
|
||||
)
|
||||
|
||||
search_response = client.get("/search", params={"q": "email"})
|
||||
@@ -367,6 +417,99 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
def test_ui_manual_registry_entry_loop(tmp_path):
|
||||
source = tmp_path / "manual-repo"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text("# Manual Repo\n", encoding="utf-8")
|
||||
|
||||
def override_settings():
|
||||
return Settings(
|
||||
database_path=str(tmp_path / "ui-manual.sqlite3"),
|
||||
checkout_root=str(tmp_path / "ui-manual-checkouts"),
|
||||
)
|
||||
|
||||
app.dependency_overrides[get_settings] = override_settings
|
||||
client = TestClient(app)
|
||||
try:
|
||||
create_response = client.post(
|
||||
"/ui/repos",
|
||||
data={"url": str(source), "branch": "main"},
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert create_response.status_code == 303
|
||||
repository_path = create_response.headers["location"]
|
||||
repository_id = int(repository_path.rsplit("/", 1)[-1])
|
||||
|
||||
detail_response = client.get(repository_path)
|
||||
assert detail_response.status_code == 200
|
||||
assert "Manual Registry Entry" in detail_response.text
|
||||
|
||||
ability_response = client.post(
|
||||
f"{repository_path}/abilities",
|
||||
data={
|
||||
"name": "Manual Ability",
|
||||
"description": "Curated by hand.",
|
||||
"confidence": "0.95",
|
||||
},
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert ability_response.status_code == 303
|
||||
ability_id = client.get(f"/repos/{repository_id}/ability-map").json()[
|
||||
"abilities"
|
||||
][0]["id"]
|
||||
|
||||
capability_response = client.post(
|
||||
f"{repository_path}/capabilities",
|
||||
data={
|
||||
"ability_id": str(ability_id),
|
||||
"name": "Manual Capability",
|
||||
"description": "Curated capability.",
|
||||
"inputs": "request, context",
|
||||
"outputs": "response",
|
||||
"confidence": "0.9",
|
||||
},
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert capability_response.status_code == 303
|
||||
capability_id = client.get(f"/repos/{repository_id}/ability-map").json()[
|
||||
"abilities"
|
||||
][0]["capabilities"][0]["id"]
|
||||
|
||||
feature_response = client.post(
|
||||
f"{repository_path}/features",
|
||||
data={
|
||||
"capability_id": str(capability_id),
|
||||
"name": "Manual API",
|
||||
"type": "REST endpoint",
|
||||
"location": "src/manual.py",
|
||||
"confidence": "0.88",
|
||||
},
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert feature_response.status_code == 303
|
||||
|
||||
evidence_response = client.post(
|
||||
f"{repository_path}/evidence",
|
||||
data={
|
||||
"capability_id": str(capability_id),
|
||||
"type": "documentation",
|
||||
"reference": "README.md",
|
||||
"strength": "medium",
|
||||
},
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert evidence_response.status_code == 303
|
||||
|
||||
detail_response = client.get(repository_path)
|
||||
assert "Manual Ability" in detail_response.text
|
||||
assert "Manual Capability" in detail_response.text
|
||||
assert "Manual API" in detail_response.text
|
||||
assert "README.md" in detail_response.text
|
||||
assert "ID " in detail_response.text
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
def test_api_rejects_candidate_capability_feature_and_evidence(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
|
||||
Reference in New Issue
Block a user