Application fully migrated to modular approach

This commit is contained in:
2025-09-13 21:30:40 +02:00
parent c7d6b33cd5
commit b9fe91ab88
38 changed files with 509 additions and 265 deletions

View File

@@ -5,15 +5,15 @@ import pytest
class TestErrorHandling:
def test_invalid_json(self, client, auth_headers):
"""Test handling of invalid JSON"""
response = client.post("/api/v1/products",
response = client.post("/api/v1/product",
headers=auth_headers,
data="invalid json")
content="invalid json")
assert response.status_code == 422 # Validation error
def test_missing_required_fields(self, client, auth_headers):
"""Test handling of missing required fields"""
response = client.post("/api/v1/products",
response = client.post("/api/v1/product",
headers=auth_headers,
json={"title": "Test"}) # Missing product_id
@@ -21,14 +21,14 @@ class TestErrorHandling:
def test_invalid_authentication(self, client):
"""Test handling of invalid authentication"""
response = client.get("/api/v1/products",
response = client.get("/api/v1/product",
headers={"Authorization": "Bearer invalid_token"})
assert response.status_code == 403
assert response.status_code == 401 # Token is not valid
def test_nonexistent_resource(self, client, auth_headers):
"""Test handling of nonexistent resource access"""
response = client.get("/api/v1/products/NONEXISTENT", headers=auth_headers)
response = client.get("/api/v1/product/NONEXISTENT", headers=auth_headers)
assert response.status_code == 404
response = client.get("/api/v1/shop/NONEXISTENT", headers=auth_headers)
@@ -41,5 +41,5 @@ class TestErrorHandling:
"title": "Another Product"
}
response = client.post("/api/v1/products", headers=auth_headers, json=product_data)
response = client.post("/api/v1/product", headers=auth_headers, json=product_data)
assert response.status_code == 400