- Added new modules for advisor compliance, KYC sessions, and script templates, enhancing the advisor agent's capabilities. - Implemented a comprehensive API structure under the `/api/advisor-agent` prefix, ensuring clear organization and access to new features. - Established database models and repositories for compliance rules and KYC sessions, facilitating robust data management. - Integrated exception handling and response models to improve error management and user feedback. - Updated settings to include new configurations for compliance and KYC features, ensuring flexibility and adaptability. This update significantly expands the advisor agent's functionality, providing essential tools for compliance and customer interaction while maintaining a structured API design.
54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
"""投资顾问 Agent 接缝冒烟(merger · /api/advisor-agent/*)。"""
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
from app.main import app
|
|
|
|
client = TestClient(app)
|
|
|
|
def _staff_token() -> str:
|
|
response = client.post(
|
|
"/api/auth/login",
|
|
json={"actor_id": "STAFF-10086", "token_type": "staff"},
|
|
)
|
|
assert response.status_code == 200
|
|
return response.json()["data"]["access_token"]
|
|
|
|
def test_advisor_compliance_ping_returns_ok_envelope():
|
|
token = _staff_token()
|
|
response = client.get(
|
|
"/api/advisor-agent/compliance/ping",
|
|
headers={"Authorization": f"Bearer {token}", "X-Trace-Id": "trace-advisor-001"},
|
|
)
|
|
assert response.status_code == 200
|
|
body = response.json()
|
|
assert body["data"]["module"] == "advisor-compliance"
|
|
assert body["trace_id"] == "trace-advisor-001"
|
|
|
|
def test_advisor_module_ping_routes_are_mounted():
|
|
token = _staff_token()
|
|
routes = [
|
|
("/api/advisor-agent/compliance/ping", "advisor-compliance"),
|
|
("/api/advisor-agent/script-templates/ping", "templates"),
|
|
("/api/advisor-agent/market-alerts/ping", "market"),
|
|
("/api/advisor-agent/kyc/ping", "kyc"),
|
|
("/api/advisor-agent/allocation/ping", "allocation"),
|
|
("/api/advisor-agent/dashboard/ping", "dashboard"),
|
|
]
|
|
for url, _ in routes:
|
|
response = client.get(
|
|
url,
|
|
headers={"Authorization": f"Bearer {token}", "X-Trace-Id": f"trace-{url}"},
|
|
)
|
|
assert response.status_code == 200, url
|
|
assert response.json()["trace_id"] == f"trace-{url}"
|
|
|
|
def test_platform_compliance_suitability_unchanged():
|
|
token = _staff_token()
|
|
response = client.post(
|
|
"/api/compliance/suitability-check",
|
|
json={"customer_id": "CUST-1001", "product_id": "PROD-001"},
|
|
headers={"Authorization": f"Bearer {token}"},
|
|
)
|
|
assert response.status_code in (200, 403, 404)
|