major refactoring adding vendor and customer features

This commit is contained in:
2025-10-11 09:09:25 +02:00
parent f569995883
commit dd16198276
126 changed files with 15109 additions and 3747 deletions

View File

@@ -29,7 +29,7 @@ class TestErrorHandling:
def test_missing_required_fields_vendor_creation(self, client, auth_headers):
"""Test validation errors for missing required fields"""
# Missing vendor_name
# Missing name
response = client.post(
"/api/v1/vendor",
headers=auth_headers,
@@ -50,7 +50,7 @@ class TestErrorHandling:
headers=auth_headers,
json={
"vendor_code": "INVALID@VENDOR!",
"vendor_name": "Test Vendor"
"name": "Test Vendor"
}
)
@@ -117,7 +117,7 @@ class TestErrorHandling:
"""Test creating vendor with duplicate vendor code"""
vendor_data = {
"vendor_code": test_vendor.vendor_code,
"vendor_name": "Duplicate Vendor"
"name": "Duplicate Vendor"
}
response = client.post("/api/v1/vendor", headers=auth_headers, json=vendor_data)
@@ -172,7 +172,7 @@ class TestErrorHandling:
for i in range(6): # Assume limit is 5
vendor_data = {
"vendor_code": f"VENDOR{i:03d}",
"vendor_name": f"Test Vendor {i}"
"name": f"Test Vendor {i}"
}
response = client.post("/api/v1/vendor", headers=auth_headers, json=vendor_data)
vendors_created.append(response)
@@ -204,15 +204,15 @@ class TestErrorHandling:
assert data["status_code"] == 422
assert data["details"]["field"] == "gtin"
def test_stock_insufficient_quantity(self, client, auth_headers, test_vendor, test_marketplace_product):
"""Test business logic error for insufficient stock"""
# First create some stock
stock_data = {
def test_inventory_insufficient_quantity(self, client, auth_headers, test_vendor, test_marketplace_product):
"""Test business logic error for insufficient inventory"""
# First create some inventory
inventory_data = {
"gtin": test_marketplace_product.gtin,
"location": "WAREHOUSE_A",
"quantity": 5
}
client.post("/api/v1/stock", headers=auth_headers, json=stock_data)
client.post("/api/v1/inventory", headers=auth_headers, json=inventory_data)
# Try to remove more than available using your remove endpoint
remove_data = {
@@ -220,12 +220,12 @@ class TestErrorHandling:
"location": "WAREHOUSE_A",
"quantity": 10 # More than the 5 we added
}
response = client.post("/api/v1/stock/remove", headers=auth_headers, json=remove_data)
response = client.post("/api/v1/inventory/remove", headers=auth_headers, json=remove_data)
# This should ALWAYS fail with insufficient stock error
# This should ALWAYS fail with insufficient inventory error
assert response.status_code == 400
data = response.json()
assert data["error_code"] == "INSUFFICIENT_STOCK"
assert data["error_code"] == "INSUFFICIENT_INVENTORY"
assert data["status_code"] == 400
assert "requested_quantity" in data["details"]
assert "available_quantity" in data["details"]
@@ -267,7 +267,7 @@ class TestErrorHandling:
large_description = "x" * 100000 # Very long description
vendor_data = {
"vendor_code": "LARGEVENDOR",
"vendor_name": "Large Vendor",
"name": "Large Vendor",
"description": large_description
}