generated from coulomb/repo-seed
first usable curator UI
This commit is contained in:
@@ -72,6 +72,33 @@ def test_api_manual_registry_loop(tmp_path):
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
def test_api_registers_repository_from_url_metadata(tmp_path):
|
||||
source = tmp_path / "metadata-api"
|
||||
source.mkdir()
|
||||
(source / "package.json").write_text(
|
||||
'{"name":"metadata-api","description":"Imported through the API."}',
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
def override_settings():
|
||||
return Settings(
|
||||
database_path=str(tmp_path / "metadata-api.sqlite3"),
|
||||
checkout_root=str(tmp_path / "metadata-api-checkouts"),
|
||||
)
|
||||
|
||||
app.dependency_overrides[get_settings] = override_settings
|
||||
client = TestClient(app)
|
||||
try:
|
||||
response = client.post("/repos", json={"url": str(source)})
|
||||
|
||||
assert response.status_code == 201
|
||||
repository = response.json()
|
||||
assert repository["name"] == "metadata-api"
|
||||
assert repository["description"] == "Imported through the API."
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
def test_api_analysis_run_loop(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
@@ -139,3 +166,70 @@ def test_api_analysis_run_loop(tmp_path):
|
||||
assert ("framework", "Vite", "package.json") in fact_names
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text("# UI Repo\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",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
def override_settings():
|
||||
return Settings(
|
||||
database_path=str(tmp_path / "ui.sqlite3"),
|
||||
checkout_root=str(tmp_path / "ui-checkouts"),
|
||||
)
|
||||
|
||||
app.dependency_overrides[get_settings] = override_settings
|
||||
client = TestClient(app)
|
||||
try:
|
||||
index_response = client.get("/ui")
|
||||
assert index_response.status_code == 200
|
||||
assert "Register Repository" in index_response.text
|
||||
|
||||
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"]
|
||||
|
||||
detail_response = client.get(repository_path)
|
||||
assert detail_response.status_code == 200
|
||||
assert "Run Analysis" in detail_response.text
|
||||
|
||||
run_response = client.post(
|
||||
f"{repository_path}/analysis-runs",
|
||||
data={"source_path": ""},
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert run_response.status_code == 303
|
||||
run_path = run_response.headers["location"]
|
||||
|
||||
run_detail = client.get(run_path)
|
||||
assert run_detail.status_code == 200
|
||||
assert "Candidate Graph" in run_detail.text
|
||||
|
||||
approve_response = client.post(
|
||||
f"{run_path}/candidate-graph/approve",
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert approve_response.status_code == 303
|
||||
|
||||
approved_detail = client.get(approve_response.headers["location"])
|
||||
assert approved_detail.status_code == 200
|
||||
assert "Approved Ability Map" in approved_detail.text
|
||||
assert "Review UI Repo Repository Usefulness" in approved_detail.text
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
Reference in New Issue
Block a user