feat(platform): 顯示全域產品資產納管
Some checks failed
Code Review / ai-code-review (push) Successful in 14s
CD Pipeline / tests (push) Successful in 1m33s
CD Pipeline / build-and-deploy (push) Successful in 4m17s
CD Pipeline / post-deploy-checks (push) Has been cancelled

This commit is contained in:
Your Name
2026-06-14 15:18:54 +08:00
parent 30f2f490c7
commit fb5c6fbadd
7 changed files with 1146 additions and 8 deletions

View File

@@ -0,0 +1,83 @@
from __future__ import annotations
from src.api.v1.platform.tenants import ListTenantsResponse
from src.services.platform_operator_service import build_tenant_asset_inventory
def test_tenant_asset_inventory_merges_products_routes_and_repos() -> None:
tenants = [
{
"project_id": "awoooi",
"display_name": "AWOOOI",
"migration_mode": "shadow",
"budget_limit_usd": None,
"is_active": True,
"created_at": "2026-06-14T00:00:00+08:00",
}
]
inventory = build_tenant_asset_inventory(tenants)
summary = inventory["summary"]
assert inventory["schema_version"] == "awooop_tenant_asset_inventory_v1"
assert summary["tenant_table_count"] == 1
assert summary["product_surface_count"] >= 10
assert summary["public_route_count"] >= 17
assert summary["source_candidate_repo_count"] == 10
assert summary["source_in_scope_repo_count"] == 9
assert summary["source_primary_ready_count"] == 0
assert summary["owner_response_accepted_count"] == 0
assert summary["runtime_gate_count"] == 0
assert summary["action_button_count"] == 0
product_ids = {item["product_id"] for item in inventory["products"]}
assert {
"awoooi",
"ewoooc",
"vibework",
"agent-bounty-protocol",
"stockplatform",
"bitan-pharmacy",
"tsenyang-website",
}.issubset(product_ids)
route_domains = {item["domain"] for item in inventory["public_routes"]}
assert {
"awoooi.wooo.work",
"stock.wooo.work",
"bitan.wooo.work",
"mo.wooo.work",
"vibework.wooo.work",
"agent.wooo.work",
"tsenyang.com",
}.issubset(route_domains)
source_repos = {item["github_repo"] for item in inventory["source_repos"]}
assert "owenhytsai/VibeWork" in source_repos
assert "owenhytsai/agent-bounty-protocol" in source_repos
assert all(item["runtime_gate_count"] == 0 for item in inventory["source_repos"])
assert all(item["action_button_count"] == 0 for item in inventory["public_routes"])
def test_tenant_response_model_keeps_asset_inventory_contract() -> None:
tenant = {
"project_id": "awoooi",
"display_name": "AWOOOI",
"migration_mode": "shadow",
"budget_limit_usd": None,
"is_active": True,
"created_at": "2026-06-14T00:00:00+08:00",
}
inventory = build_tenant_asset_inventory([tenant])
response = ListTenantsResponse.model_validate(
{
"tenants": [tenant],
"total": 1,
"asset_inventory": inventory,
}
)
assert response.asset_inventory.summary.product_surface_count >= 10
assert response.asset_inventory.summary.runtime_gate_count == 0
assert response.asset_inventory.products[0].runtime_gate_count == 0