Some checks failed
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / build-and-deploy (push) Has been cancelled
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / tests (push) Has been cancelled
59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.testclient import TestClient
|
|
|
|
from src.api.v1 import agents
|
|
from src.api.v1.agents import router
|
|
|
|
|
|
def _client() -> TestClient:
|
|
app = FastAPI()
|
|
app.include_router(router, prefix="/api/v1")
|
|
return TestClient(app)
|
|
|
|
|
|
def test_canonical_routing_runtime_readback_endpoint(monkeypatch) -> None:
|
|
payload = {
|
|
"schema_version": "telegram_canonical_routing_runtime_readback_v1",
|
|
"status": "runtime_policy_enforced_product_delivery_receipts_partial",
|
|
"operation_boundaries": {
|
|
"telegram_send_performed": False,
|
|
"secret_value_read": False,
|
|
},
|
|
}
|
|
monkeypatch.setattr(
|
|
agents,
|
|
"build_canonical_telegram_routing_runtime_readback",
|
|
lambda: payload,
|
|
)
|
|
|
|
response = _client().get(
|
|
"/api/v1/agents/telegram-canonical-routing-runtime-readback"
|
|
)
|
|
|
|
assert response.status_code == 200
|
|
assert response.json() == payload
|
|
|
|
|
|
def test_canonical_routing_runtime_readback_rejects_invalid_source(
|
|
monkeypatch,
|
|
) -> None:
|
|
def invalid_source() -> dict:
|
|
raise ValueError("invalid registry")
|
|
|
|
monkeypatch.setattr(
|
|
agents,
|
|
"build_canonical_telegram_routing_runtime_readback",
|
|
invalid_source,
|
|
)
|
|
|
|
response = _client().get(
|
|
"/api/v1/agents/telegram-canonical-routing-runtime-readback"
|
|
)
|
|
|
|
assert response.status_code == 500
|
|
assert response.json() == {
|
|
"detail": "Telegram canonical routing runtime readback 無效"
|
|
}
|