generated from coulomb/repo-seed
Add registry inventory and drift views
This commit is contained in:
@@ -41,6 +41,20 @@ def test_registry_accepts_snapshot_and_queries_graph(tmp_path: Path) -> None:
|
||||
"graph": graph.to_export(),
|
||||
},
|
||||
)
|
||||
changed_export = graph.to_export()
|
||||
changed_export["nodes"] = [
|
||||
node
|
||||
for node in changed_export["nodes"]
|
||||
if node["id"] != "repo-scoping.scope-generator"
|
||||
]
|
||||
changed_snapshot = store.add_snapshot(
|
||||
"railiance-fabric",
|
||||
{
|
||||
"commit": "test-commit-2",
|
||||
"generated_at": "2026-05-17T00:01:00Z",
|
||||
"graph": changed_export,
|
||||
},
|
||||
)
|
||||
combined = store.combined_graph()
|
||||
artifact = store.add_artifact(
|
||||
{
|
||||
@@ -58,9 +72,18 @@ def test_registry_accepts_snapshot_and_queries_graph(tmp_path: Path) -> None:
|
||||
libraries = store.ingest_cyclonedx("railiance-fabric", _cyclonedx_bom())
|
||||
|
||||
assert snapshot["repo_slug"] == "railiance-fabric"
|
||||
assert changed_snapshot["commit"] == "test-commit-2"
|
||||
assert artifact["artifact_type"] == "openapi"
|
||||
assert libraries["component_count"] == 2
|
||||
assert store.list_libraries(name="jsonschema")[0]["purl"] == "pkg:pypi/jsonschema@4.18.0"
|
||||
inventory = store.repository_inventory("railiance-fabric")
|
||||
assert inventory["counts"]["snapshots"] == 2
|
||||
assert inventory["counts"]["libraries"] == 2
|
||||
diff = store.snapshot_diff("railiance-fabric")
|
||||
assert diff["from"]["commit"] == "test-commit"
|
||||
assert diff["to"]["commit"] == "test-commit-2"
|
||||
assert diff["graph"]["removed_nodes"][0]["id"] == "repo-scoping.scope-generator"
|
||||
assert store.search("jsonschema")["libraries"][0]["name"] == "jsonschema"
|
||||
assert store.graph_node_detail("flex-auth.api.http-api")["artifacts"][0]["name"] == "flex-auth OpenAPI"
|
||||
assert providers(combined, "runtime-secrets")[0]["provider_id"] == "railiance-platform.openbao.runtime-secrets"
|
||||
assert {match["status"] for match in consumers(combined, "railiance-platform.openbao.kv-v2")} >= {"exact"}
|
||||
@@ -107,9 +130,29 @@ def test_registry_http_service_serves_queries(tmp_path: Path) -> None:
|
||||
]
|
||||
) == 0
|
||||
assert store.latest_snapshot("railiance-fabric")["commit"] == "test-cli"
|
||||
second_export = build_graph([Path(".")]).to_export()
|
||||
second_export["nodes"] = second_export["nodes"][:-1]
|
||||
_post_json(
|
||||
f"{base_url}/repositories/railiance-fabric/snapshots",
|
||||
{
|
||||
"commit": "test-cli-2",
|
||||
"generated_at": "2026-05-17T00:02:00Z",
|
||||
"graph": second_export,
|
||||
},
|
||||
)
|
||||
|
||||
with urllib.request.urlopen(f"{base_url}/health", timeout=5) as response:
|
||||
assert json.loads(response.read())["status"] == "ok"
|
||||
with urllib.request.urlopen(
|
||||
f"{base_url}/repositories/railiance-fabric/snapshots",
|
||||
timeout=5,
|
||||
) as response:
|
||||
snapshots_payload = json.loads(response.read())
|
||||
with urllib.request.urlopen(
|
||||
f"{base_url}/repositories/railiance-fabric/snapshots/diff",
|
||||
timeout=5,
|
||||
) as response:
|
||||
drift_payload = json.loads(response.read())
|
||||
with urllib.request.urlopen(
|
||||
f"{base_url}/graph/providers?capability_type=runtime-secrets",
|
||||
timeout=5,
|
||||
@@ -153,6 +196,13 @@ def test_registry_http_service_serves_queries(tmp_path: Path) -> None:
|
||||
timeout=5,
|
||||
) as response:
|
||||
libraries_payload = json.loads(response.read())
|
||||
with urllib.request.urlopen(
|
||||
f"{base_url}/repositories/railiance-fabric/inventory",
|
||||
timeout=5,
|
||||
) as response:
|
||||
inventory_payload = json.loads(response.read())
|
||||
with urllib.request.urlopen(f"{base_url}/search?q=jsonschema", timeout=5) as response:
|
||||
search_payload = json.loads(response.read())
|
||||
with urllib.request.urlopen(f"{base_url}/exports/backstage", timeout=5) as response:
|
||||
backstage_payload = json.loads(response.read())
|
||||
with urllib.request.urlopen(f"{base_url}/exports/xregistry", timeout=5) as response:
|
||||
@@ -160,10 +210,14 @@ def test_registry_http_service_serves_queries(tmp_path: Path) -> None:
|
||||
with urllib.request.urlopen(f"{base_url}/exports/libraries/xregistry", timeout=5) as response:
|
||||
library_projection_payload = json.loads(response.read())
|
||||
assert providers_payload[0]["provider_id"] == "railiance-platform.openbao.runtime-secrets"
|
||||
assert snapshots_payload[0]["commit"] == "test-cli-2"
|
||||
assert drift_payload["graph"]["removed_nodes"]
|
||||
assert artifact_payload["name"] == "OpenBao KV API"
|
||||
assert artifacts_payload[0]["artifact_type"] == "openapi"
|
||||
assert library_payload["component_count"] == 2
|
||||
assert libraries_payload[0]["name"] == "jsonschema"
|
||||
assert inventory_payload["counts"]["snapshots"] == 3
|
||||
assert search_payload["libraries"][0]["name"] == "jsonschema"
|
||||
assert backstage_payload["kind"] == "BackstageCatalogProjection"
|
||||
assert "interfaces" in xregistry_payload["groups"]
|
||||
assert "libraries" in library_projection_payload["groups"]
|
||||
|
||||
Reference in New Issue
Block a user