Files
awoooi/apps/api/tests/test_awooop_tenant_asset_inventory.py
Your Name fef94df877
All checks were successful
Code Review / ai-code-review (push) Successful in 14s
CD Pipeline / tests (push) Successful in 1m29s
CD Pipeline / build-and-deploy (push) Successful in 4m26s
CD Pipeline / post-deploy-checks (push) Successful in 1m37s
feat(platform): 擴充 Tenants 全域產品資產台帳
2026-06-14 15:50:57 +08:00

99 lines
3.3 KiB
Python

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"] >= 16
assert summary["public_route_count"] >= 31
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",
"2026-fifa-world-cup",
"stockplatform",
"bitan-pharmacy",
"tsenyang-website",
"wooo-open-design",
"workflow-automation",
"data-workspace",
"security-secrets-platform",
"ai-model-gateway",
}.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",
"2026fifa.wooo.work",
"design.wooo.work",
"n8n.wooo.work",
"grist.wooo.work",
"vault.wooo.work",
"ollama.wooo.work",
"tsenyang.com",
"tsenyang.wooo.work",
}.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 "nexu-io/open-design" 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"])
assert all(item["runtime_gate_count"] == 0 for item in inventory["products"])
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 >= 16
assert response.asset_inventory.summary.runtime_gate_count == 0
assert response.asset_inventory.products[0].runtime_gate_count == 0