|
|
@ -9,7 +9,13 @@ from fastapi.exceptions import ( |
|
|
|
|
|
|
|
|
def test_request_validation_error_str_single_error(): |
|
|
def test_request_validation_error_str_single_error(): |
|
|
"""Test string representation of RequestValidationError with single error.""" |
|
|
"""Test string representation of RequestValidationError with single error.""" |
|
|
errors = [{"type": "int_parsing", "loc": ["query", "id"], "msg": "Input should be a valid integer"}] |
|
|
errors = [ |
|
|
|
|
|
{ |
|
|
|
|
|
"type": "int_parsing", |
|
|
|
|
|
"loc": ["query", "id"], |
|
|
|
|
|
"msg": "Input should be a valid integer", |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
exc = RequestValidationError(errors) |
|
|
exc = RequestValidationError(errors) |
|
|
result = str(exc) |
|
|
result = str(exc) |
|
|
|
|
|
|
|
|
@ -20,7 +26,11 @@ def test_request_validation_error_str_single_error(): |
|
|
def test_request_validation_error_str_multiple_errors(): |
|
|
def test_request_validation_error_str_multiple_errors(): |
|
|
"""Test string representation of RequestValidationError with multiple errors.""" |
|
|
"""Test string representation of RequestValidationError with multiple errors.""" |
|
|
errors = [ |
|
|
errors = [ |
|
|
{"type": "int_parsing", "loc": ["query", "id"], "msg": "Input should be a valid integer"}, |
|
|
{ |
|
|
|
|
|
"type": "int_parsing", |
|
|
|
|
|
"loc": ["query", "id"], |
|
|
|
|
|
"msg": "Input should be a valid integer", |
|
|
|
|
|
}, |
|
|
{"type": "missing", "loc": ["query", "name"], "msg": "Field required"}, |
|
|
{"type": "missing", "loc": ["query", "name"], "msg": "Field required"}, |
|
|
] |
|
|
] |
|
|
exc = RequestValidationError(errors) |
|
|
exc = RequestValidationError(errors) |
|
|
@ -33,7 +43,13 @@ def test_request_validation_error_str_multiple_errors(): |
|
|
|
|
|
|
|
|
def test_websocket_request_validation_error_str_single_error(): |
|
|
def test_websocket_request_validation_error_str_single_error(): |
|
|
"""Test string representation of WebSocketRequestValidationError with single error.""" |
|
|
"""Test string representation of WebSocketRequestValidationError with single error.""" |
|
|
errors = [{"type": "int_parsing", "loc": ["query", "id"], "msg": "Input should be a valid integer"}] |
|
|
errors = [ |
|
|
|
|
|
{ |
|
|
|
|
|
"type": "int_parsing", |
|
|
|
|
|
"loc": ["query", "id"], |
|
|
|
|
|
"msg": "Input should be a valid integer", |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
exc = WebSocketRequestValidationError(errors) |
|
|
exc = WebSocketRequestValidationError(errors) |
|
|
result = str(exc) |
|
|
result = str(exc) |
|
|
|
|
|
|
|
|
@ -44,7 +60,11 @@ def test_websocket_request_validation_error_str_single_error(): |
|
|
def test_websocket_request_validation_error_str_multiple_errors(): |
|
|
def test_websocket_request_validation_error_str_multiple_errors(): |
|
|
"""Test string representation of WebSocketRequestValidationError with multiple errors.""" |
|
|
"""Test string representation of WebSocketRequestValidationError with multiple errors.""" |
|
|
errors = [ |
|
|
errors = [ |
|
|
{"type": "int_parsing", "loc": ["query", "id"], "msg": "Input should be a valid integer"}, |
|
|
{ |
|
|
|
|
|
"type": "int_parsing", |
|
|
|
|
|
"loc": ["query", "id"], |
|
|
|
|
|
"msg": "Input should be a valid integer", |
|
|
|
|
|
}, |
|
|
{"type": "missing", "loc": ["query", "name"], "msg": "Field required"}, |
|
|
{"type": "missing", "loc": ["query", "name"], "msg": "Field required"}, |
|
|
] |
|
|
] |
|
|
exc = WebSocketRequestValidationError(errors) |
|
|
exc = WebSocketRequestValidationError(errors) |
|
|
@ -57,7 +77,13 @@ def test_websocket_request_validation_error_str_multiple_errors(): |
|
|
|
|
|
|
|
|
def test_response_validation_error_str_consistency(): |
|
|
def test_response_validation_error_str_consistency(): |
|
|
"""Test that ResponseValidationError has similar __str__ behavior.""" |
|
|
"""Test that ResponseValidationError has similar __str__ behavior.""" |
|
|
errors = [{"type": "int_parsing", "loc": ["response", "id"], "msg": "Input should be a valid integer"}] |
|
|
errors = [ |
|
|
|
|
|
{ |
|
|
|
|
|
"type": "int_parsing", |
|
|
|
|
|
"loc": ["response", "id"], |
|
|
|
|
|
"msg": "Input should be a valid integer", |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
exc = ResponseValidationError(errors) |
|
|
exc = ResponseValidationError(errors) |
|
|
result = str(exc) |
|
|
result = str(exc) |
|
|
|
|
|
|
|
|
|