generated from john/python-template
This commit is contained in:
+18
-7
@@ -21,6 +21,8 @@ class TestErrorCategoryContract:
|
||||
assert ErrorCategory.NOT_FOUND.value == "not_found_error"
|
||||
assert ErrorCategory.CONFLICT.value == "conflict_error"
|
||||
assert ErrorCategory.EXTERNAL_PROVIDER.value == "external_provider_error"
|
||||
assert ErrorCategory.EXTERNAL_TIMEOUT.value == "external_timeout_error"
|
||||
assert ErrorCategory.PROCESSING.value == "processing_error"
|
||||
assert ErrorCategory.INFRA_TRANSIENT.value == "infrastructure_transient_error"
|
||||
assert ErrorCategory.INFRA_PERSISTENT.value == "infrastructure_persistent_error"
|
||||
assert ErrorCategory.INTERNAL_UNEXPECTED.value == "internal_unexpected_error"
|
||||
@@ -49,11 +51,20 @@ class TestAppErrorHelpers:
|
||||
|
||||
def test_envelope_categories_use_canonical_contract_values(self):
|
||||
"""API/UI envelope categories are normalized to canonical short identifiers."""
|
||||
validation = AppError("x", category=ErrorCategory.USER_INPUT)
|
||||
timeout = AppError("x", category=ErrorCategory.INFRA_TRANSIENT)
|
||||
internal = AppError("x", category=ErrorCategory.INTERNAL_UNEXPECTED)
|
||||
expected_mapping = {
|
||||
ErrorCategory.VALIDATION: "validation",
|
||||
ErrorCategory.USER_INPUT: "validation",
|
||||
ErrorCategory.NOT_FOUND: "not_found",
|
||||
ErrorCategory.CONFLICT: "conflict",
|
||||
ErrorCategory.EXTERNAL_PROVIDER: "external",
|
||||
ErrorCategory.EXTERNAL_TIMEOUT: "timeout",
|
||||
ErrorCategory.INFRA_TRANSIENT: "timeout",
|
||||
ErrorCategory.PROCESSING: "internal",
|
||||
ErrorCategory.INFRA_PERSISTENT: "internal",
|
||||
ErrorCategory.INTERNAL_UNEXPECTED: "internal",
|
||||
}
|
||||
|
||||
assert canonical_error_category(validation) == "validation"
|
||||
assert canonical_error_category(timeout) == "timeout"
|
||||
assert canonical_error_category(internal) == "internal"
|
||||
assert build_error_envelope(validation).category == "validation"
|
||||
for category, expected in expected_mapping.items():
|
||||
err = AppError("x", category=category)
|
||||
assert canonical_error_category(err) == expected
|
||||
assert build_error_envelope(err).category == expected
|
||||
|
||||
Reference in New Issue
Block a user