marketplace refactoring
This commit is contained in:
@@ -104,13 +104,13 @@ class TestErrorHandling:
|
||||
|
||||
def test_product_not_found(self, client, auth_headers):
|
||||
"""Test accessing non-existent product"""
|
||||
response = client.get("/api/v1/product/NONEXISTENT", headers=auth_headers)
|
||||
response = client.get("/api/v1/marketplace/product/NONEXISTENT", headers=auth_headers)
|
||||
|
||||
assert response.status_code == 404
|
||||
data = response.json()
|
||||
assert data["error_code"] == "PRODUCT_NOT_FOUND"
|
||||
assert data["status_code"] == 404
|
||||
assert data["details"]["resource_type"] == "Product"
|
||||
assert data["details"]["resource_type"] == "MarketplaceProduct"
|
||||
assert data["details"]["identifier"] == "NONEXISTENT"
|
||||
|
||||
def test_duplicate_shop_creation(self, client, auth_headers, test_shop):
|
||||
@@ -128,21 +128,21 @@ class TestErrorHandling:
|
||||
assert data["status_code"] == 409
|
||||
assert data["details"]["shop_code"] == test_shop.shop_code.upper()
|
||||
|
||||
def test_duplicate_product_creation(self, client, auth_headers, test_product):
|
||||
def test_duplicate_product_creation(self, client, auth_headers, test_marketplace_product):
|
||||
"""Test creating product with duplicate product ID"""
|
||||
product_data = {
|
||||
"product_id": test_product.product_id,
|
||||
"title": "Duplicate Product",
|
||||
"marketplace_product_id": test_marketplace_product.marketplace_product_id,
|
||||
"title": "Duplicate MarketplaceProduct",
|
||||
"gtin": "1234567890123"
|
||||
}
|
||||
|
||||
response = client.post("/api/v1/product", headers=auth_headers, json=product_data)
|
||||
response = client.post("/api/v1/marketplace/product", headers=auth_headers, json=product_data)
|
||||
|
||||
assert response.status_code == 409
|
||||
data = response.json()
|
||||
assert data["error_code"] == "PRODUCT_ALREADY_EXISTS"
|
||||
assert data["status_code"] == 409
|
||||
assert data["details"]["product_id"] == test_product.product_id
|
||||
assert data["details"]["marketplace_product_id"] == test_marketplace_product.marketplace_product_id
|
||||
|
||||
def test_unauthorized_shop_access(self, client, auth_headers, inactive_shop):
|
||||
"""Test accessing shop without proper permissions"""
|
||||
@@ -191,12 +191,12 @@ class TestErrorHandling:
|
||||
def test_validation_error_invalid_gtin(self, client, auth_headers):
|
||||
"""Test validation error for invalid GTIN format"""
|
||||
product_data = {
|
||||
"product_id": "TESTPROD001",
|
||||
"title": "Test Product",
|
||||
"marketplace_product_id": "TESTPROD001",
|
||||
"title": "Test MarketplaceProduct",
|
||||
"gtin": "invalid_gtin_format"
|
||||
}
|
||||
|
||||
response = client.post("/api/v1/product", headers=auth_headers, json=product_data)
|
||||
response = client.post("/api/v1/marketplace/product", headers=auth_headers, json=product_data)
|
||||
|
||||
assert response.status_code == 422
|
||||
data = response.json()
|
||||
@@ -204,11 +204,11 @@ class TestErrorHandling:
|
||||
assert data["status_code"] == 422
|
||||
assert data["details"]["field"] == "gtin"
|
||||
|
||||
def test_stock_insufficient_quantity(self, client, auth_headers, test_shop, test_product):
|
||||
def test_stock_insufficient_quantity(self, client, auth_headers, test_shop, test_marketplace_product):
|
||||
"""Test business logic error for insufficient stock"""
|
||||
# First create some stock
|
||||
stock_data = {
|
||||
"gtin": test_product.gtin,
|
||||
"gtin": test_marketplace_product.gtin,
|
||||
"location": "WAREHOUSE_A",
|
||||
"quantity": 5
|
||||
}
|
||||
@@ -216,7 +216,7 @@ class TestErrorHandling:
|
||||
|
||||
# Try to remove more than available using your remove endpoint
|
||||
remove_data = {
|
||||
"gtin": test_product.gtin,
|
||||
"gtin": test_marketplace_product.gtin,
|
||||
"location": "WAREHOUSE_A",
|
||||
"quantity": 10 # More than the 5 we added
|
||||
}
|
||||
@@ -345,7 +345,7 @@ class TestErrorHandling:
|
||||
"""Test that all error responses follow consistent structure"""
|
||||
test_cases = [
|
||||
("/api/v1/shop/NONEXISTENT", 404),
|
||||
("/api/v1/product/NONEXISTENT", 404),
|
||||
("/api/v1/marketplace/product/NONEXISTENT", 404),
|
||||
]
|
||||
|
||||
for endpoint, expected_status in test_cases:
|
||||
|
||||
Reference in New Issue
Block a user