QC check
This commit is contained in:
@@ -1,3 +1,2 @@
|
||||
# tests/system/__init__.py
|
||||
"""System-level tests - full application behavior."""
|
||||
|
||||
|
||||
@@ -3,4 +3,3 @@
|
||||
import pytest
|
||||
|
||||
# Add any system-specific fixtures here if needed
|
||||
|
||||
|
||||
@@ -72,13 +72,17 @@ class TestErrorHandling:
|
||||
"""Test handling of various malformed requests"""
|
||||
# Test extremely long URLs
|
||||
long_search = "x" * 10000
|
||||
response = client.get(f"/api/v1/product?search={long_search}", headers=auth_headers)
|
||||
response = client.get(
|
||||
f"/api/v1/product?search={long_search}", headers=auth_headers
|
||||
)
|
||||
# Should handle gracefully, either 200 with no results or 422 for too long
|
||||
assert response.status_code in [200, 422]
|
||||
|
||||
# Test special characters in parameters
|
||||
special_chars = "!@#$%^&*(){}[]|\\:;\"'<>,.?/~`"
|
||||
response = client.get(f"/api/v1/product?search={special_chars}", headers=auth_headers)
|
||||
response = client.get(
|
||||
f"/api/v1/product?search={special_chars}", headers=auth_headers
|
||||
)
|
||||
# Should handle gracefully
|
||||
assert response.status_code in [200, 422]
|
||||
|
||||
@@ -95,9 +99,13 @@ class TestErrorHandling:
|
||||
response = client.post(
|
||||
"/api/v1/product",
|
||||
headers={**auth_headers, "Content-Type": "application/xml"},
|
||||
content="<xml>not json</xml>"
|
||||
content="<xml>not json</xml>",
|
||||
)
|
||||
assert response.status_code in [400, 422, 415] # Bad request or unsupported media type
|
||||
assert response.status_code in [
|
||||
400,
|
||||
422,
|
||||
415,
|
||||
] # Bad request or unsupported media type
|
||||
|
||||
def test_large_payload_handling(self, client, auth_headers):
|
||||
"""Test handling of unusually large payloads"""
|
||||
@@ -105,9 +113,9 @@ class TestErrorHandling:
|
||||
large_data = {
|
||||
"product_id": "LARGE_TEST",
|
||||
"title": "Large Test Product",
|
||||
"description": "x" * 50000 # Very long description
|
||||
"description": "x" * 50000, # Very long description
|
||||
}
|
||||
|
||||
response = client.post("/api/v1/product", headers=auth_headers, json=large_data)
|
||||
# Should either accept it or reject with 422 (too large)
|
||||
assert response.status_code in [200, 201, 422, 413]
|
||||
assert response.status_code in [200, 201, 422, 413]
|
||||
|
||||
Reference in New Issue
Block a user