b71c66917c
- ruff: contextlib.suppress al posto di try/except/pass (client_registry, test_env_routing) - rimozione services/ legacy (residuo da git rm) - fix integration test fixture: rimosso sys.modules.pop che inquinava module references nei test successivi (test_audit, test_client_init_default_http) 254 test passano. Ruff: clean. Mypy: 68 warning preesistenti dal codice V1 migrato (strict=false). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
30 lines
871 B
Python
30 lines
871 B
Python
from __future__ import annotations
|
|
|
|
from cerbero_mcp.common.errors import HTTP_CODE_MAP, error_envelope
|
|
|
|
|
|
def test_envelope_minimal():
|
|
e = error_envelope(type_="x", code="C", message="m", retryable=False)
|
|
assert e["error"]["code"] == "C"
|
|
assert e["error"]["retryable"] is False
|
|
assert "request_id" in e
|
|
assert "data_timestamp" in e
|
|
|
|
|
|
def test_envelope_with_suggested_fix_and_details():
|
|
e = error_envelope(
|
|
type_="validation_error",
|
|
code="INVALID_INPUT",
|
|
message="bad",
|
|
retryable=False,
|
|
suggested_fix="check field x",
|
|
details={"field": "x"},
|
|
)
|
|
assert e["error"]["suggested_fix"] == "check field x"
|
|
assert e["error"]["details"] == {"field": "x"}
|
|
|
|
|
|
def test_http_code_map_has_common_codes():
|
|
assert HTTP_CODE_MAP[401] == "UNAUTHORIZED"
|
|
assert HTTP_CODE_MAP[502] == "UPSTREAM_ERROR"
|