generated from coulomb/repo-seed
Add trusted auto-approval migration inventory
This commit is contained in:
@@ -3,6 +3,9 @@ import sqlite3
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from repo_registry.core.service import RegistryService
|
||||
from repo_registry.repo_ingestion.git import GitIngestionService
|
||||
from repo_registry.storage.sqlite import RegistryStore
|
||||
from repo_registry.web_api import app as app_module
|
||||
from repo_registry.web_api.app import Settings, app, get_service, get_settings
|
||||
|
||||
@@ -191,6 +194,48 @@ def test_quality_gate_override_api_records_auditable_override(tmp_path):
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
def test_trusted_auto_approval_migration_inventory_api(tmp_path):
|
||||
source = tmp_path / "legacy-api-repo"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text("# Legacy API Repo\nReports health.\n", encoding="utf-8")
|
||||
(source / "app.py").write_text('@app.get("/health")\ndef health():\n return {}\n', encoding="utf-8")
|
||||
database_path = str(tmp_path / "legacy-auto-approval.sqlite3")
|
||||
store = RegistryStore(database_path)
|
||||
store.initialize()
|
||||
service = RegistryService(
|
||||
store,
|
||||
ingestion=GitIngestionService(tmp_path / "checkouts"),
|
||||
)
|
||||
repository = service.register_repository(name="Legacy API Repo", url=str(source))
|
||||
summary = service.analyze_repository(repository.id, use_llm_assistance=False)
|
||||
service.trusted_auto_approve_candidate_graph(
|
||||
repository.id,
|
||||
summary.analysis_run.id,
|
||||
allow_deprecated_migration_mode=True,
|
||||
)
|
||||
|
||||
def override_settings():
|
||||
return Settings(
|
||||
database_path=database_path,
|
||||
checkout_root=str(tmp_path / "checkouts"),
|
||||
)
|
||||
|
||||
app.dependency_overrides[get_settings] = override_settings
|
||||
client = TestClient(app)
|
||||
try:
|
||||
response = client.get("/review/migrations/trusted-auto-approvals")
|
||||
|
||||
assert response.status_code == 200
|
||||
records = response.json()
|
||||
assert records[0]["repository_id"] == repository.id
|
||||
assert records[0]["repository_name"] == "Legacy API Repo"
|
||||
assert records[0]["analysis_run_id"] == summary.analysis_run.id
|
||||
assert records[0]["current_approved_ability_count"] == 1
|
||||
assert "rebuild" in records[0]["recommended_next_step"]
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
def test_openapi_contract_snapshot_for_stable_agent_paths():
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -246,6 +291,12 @@ def test_openapi_contract_snapshot_for_stable_agent_paths():
|
||||
"success_schema": "QualityCriteriaRegistryResponse",
|
||||
}
|
||||
},
|
||||
"/review/migrations/trusted-auto-approvals": {
|
||||
"get": {
|
||||
"tags": ["review"],
|
||||
"success_schema": "list[TrustedAutoApprovalMigrationRecordResponse]",
|
||||
}
|
||||
},
|
||||
"/repos": {
|
||||
"get": {"tags": ["repositories"], "success_schema": "list[RepositoryResponse]"},
|
||||
"post": {"tags": ["repositories"], "success_schema": "RepositoryResponse"},
|
||||
|
||||
Reference in New Issue
Block a user