generated from coulomb/repo-seed
Status drift warnings
This commit is contained in:
@@ -182,6 +182,12 @@ def test_openapi_contract_snapshot_for_stable_agent_paths():
|
||||
"/repos/{repository_id}/analysis-runs/{base_analysis_run_id}/diff/{target_analysis_run_id}": {
|
||||
"get": {"tags": ["review"], "success_schema": "AnalysisRunDiffResponse"}
|
||||
},
|
||||
"/repos/{repository_id}/characteristics/rebuild": {
|
||||
"post": {
|
||||
"tags": ["analysis"],
|
||||
"success_schema": "CharacteristicRebuildResponse",
|
||||
}
|
||||
},
|
||||
"/repos/{repository_id}/analysis-runs/{analysis_run_id}/candidate-abilities/{candidate_ability_id}": {
|
||||
"patch": {"tags": ["review"], "success_schema": "CandidateGraphResponse"}
|
||||
},
|
||||
@@ -1767,7 +1773,118 @@ def test_ui_register_and_explore_lands_on_analysis_result(tmp_path):
|
||||
|
||||
repository_detail = client.get("/ui/repos/1")
|
||||
assert repository_detail.status_code == 200
|
||||
assert "Use Approved Registry" in repository_detail.text
|
||||
assert "Latest Candidate Graph" in repository_detail.text
|
||||
assert "Rebuild Characteristics" in repository_detail.text
|
||||
assert "Use Approved Registry" not in repository_detail.text
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
def test_rebuild_characteristics_endpoint_dry_run_and_confirm(tmp_path):
|
||||
source = tmp_path / "rebuild-api"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text("# Rebuild API\nReports status.\n", encoding="utf-8")
|
||||
(source / "app.py").write_text('@app.get("/status")\ndef status():\n return {}\n', encoding="utf-8")
|
||||
|
||||
def override_settings():
|
||||
return Settings(
|
||||
database_path=str(tmp_path / "rebuild-api.sqlite3"),
|
||||
checkout_root=str(tmp_path / "rebuild-api-checkouts"),
|
||||
)
|
||||
|
||||
app.dependency_overrides[get_settings] = override_settings
|
||||
client = TestClient(app)
|
||||
try:
|
||||
repository_id = client.post(
|
||||
"/repos",
|
||||
json={"name": "Rebuild API", "url": str(source)},
|
||||
).json()["id"]
|
||||
run_id = client.post(
|
||||
f"/repos/{repository_id}/analysis-runs",
|
||||
json={"source_path": str(source), "use_llm_assistance": False},
|
||||
).json()["analysis_run"]["id"]
|
||||
approve_response = client.post(
|
||||
f"/repos/{repository_id}/analysis-runs/{run_id}/candidate-graph/approve",
|
||||
json={"notes": "approve before rebuild"},
|
||||
)
|
||||
assert approve_response.status_code == 200
|
||||
|
||||
dry_run_response = client.post(
|
||||
f"/repos/{repository_id}/characteristics/rebuild",
|
||||
json={
|
||||
"dry_run": True,
|
||||
"source_path": str(source),
|
||||
"use_llm_assistance": False,
|
||||
},
|
||||
)
|
||||
assert dry_run_response.status_code == 200
|
||||
dry_run = dry_run_response.json()
|
||||
assert dry_run["cleared_approved"] is False
|
||||
assert dry_run["previous_counts"]["abilities"] == 1
|
||||
assert dry_run["previous_ids"]["abilities"]
|
||||
|
||||
rejected_response = client.post(
|
||||
f"/repos/{repository_id}/characteristics/rebuild",
|
||||
json={
|
||||
"dry_run": False,
|
||||
"confirm": False,
|
||||
"source_path": str(source),
|
||||
"use_llm_assistance": False,
|
||||
},
|
||||
)
|
||||
assert rejected_response.status_code == 400
|
||||
|
||||
confirmed_response = client.post(
|
||||
f"/repos/{repository_id}/characteristics/rebuild",
|
||||
json={
|
||||
"dry_run": False,
|
||||
"confirm": True,
|
||||
"source_path": str(source),
|
||||
"use_llm_assistance": False,
|
||||
},
|
||||
)
|
||||
assert confirmed_response.status_code == 200
|
||||
confirmed = confirmed_response.json()
|
||||
assert confirmed["cleared_approved"] is True
|
||||
assert client.get(f"/repos/{repository_id}/ability-map").json()["abilities"] == []
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
def test_ui_rebuild_characteristics_form_runs_dry_run(tmp_path):
|
||||
source = tmp_path / "ui-rebuild"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text("# UI Rebuild\nReports status.\n", encoding="utf-8")
|
||||
|
||||
def override_settings():
|
||||
return Settings(
|
||||
database_path=str(tmp_path / "ui-rebuild.sqlite3"),
|
||||
checkout_root=str(tmp_path / "ui-rebuild-checkouts"),
|
||||
)
|
||||
|
||||
app.dependency_overrides[get_settings] = override_settings
|
||||
client = TestClient(app)
|
||||
try:
|
||||
repository_id = client.post(
|
||||
"/repos",
|
||||
json={"name": "UI Rebuild", "url": str(source)},
|
||||
).json()["id"]
|
||||
|
||||
response = client.post(
|
||||
f"/ui/repos/{repository_id}/characteristics/rebuild",
|
||||
data={
|
||||
"source_path": str(source),
|
||||
"dry_run": "1",
|
||||
"use_llm_assistance": "",
|
||||
"use_cached_checkout": "",
|
||||
},
|
||||
follow_redirects=False,
|
||||
)
|
||||
|
||||
assert response.status_code == 303
|
||||
assert f"/ui/repos/{repository_id}/analysis-runs/" in response.headers["location"]
|
||||
detail = client.get(response.headers["location"])
|
||||
assert "dry_run_rebuild_characteristics_from_scratch" in detail.text
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user