style: apply black and isort formatting across entire codebase
- Standardize quote style (single to double quotes) - Reorder and group imports alphabetically - Fix line breaks and indentation for consistency - Apply PEP 8 formatting standards Also updated Makefile to exclude both venv and .venv from code quality checks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,9 @@ class TestInventoryAPI:
|
||||
"quantity": 100,
|
||||
}
|
||||
|
||||
response = client.post("/api/v1/inventory", headers=auth_headers, json=inventory_data)
|
||||
response = client.post(
|
||||
"/api/v1/inventory", headers=auth_headers, json=inventory_data
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
@@ -38,7 +40,9 @@ class TestInventoryAPI:
|
||||
"quantity": 75,
|
||||
}
|
||||
|
||||
response = client.post("/api/v1/inventory", headers=auth_headers, json=inventory_data)
|
||||
response = client.post(
|
||||
"/api/v1/inventory", headers=auth_headers, json=inventory_data
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
@@ -52,7 +56,9 @@ class TestInventoryAPI:
|
||||
"quantity": 100,
|
||||
}
|
||||
|
||||
response = client.post("/api/v1/inventory", headers=auth_headers, json=inventory_data)
|
||||
response = client.post(
|
||||
"/api/v1/inventory", headers=auth_headers, json=inventory_data
|
||||
)
|
||||
|
||||
assert response.status_code == 422
|
||||
data = response.json()
|
||||
@@ -60,7 +66,9 @@ class TestInventoryAPI:
|
||||
assert data["status_code"] == 422
|
||||
assert "GTIN is required" in data["message"]
|
||||
|
||||
def test_set_inventory_invalid_quantity_validation_error(self, client, auth_headers):
|
||||
def test_set_inventory_invalid_quantity_validation_error(
|
||||
self, client, auth_headers
|
||||
):
|
||||
"""Test setting inventory with invalid quantity returns InvalidQuantityException"""
|
||||
inventory_data = {
|
||||
"gtin": "1234567890123",
|
||||
@@ -68,7 +76,9 @@ class TestInventoryAPI:
|
||||
"quantity": -10, # Negative quantity
|
||||
}
|
||||
|
||||
response = client.post("/api/v1/inventory", headers=auth_headers, json=inventory_data)
|
||||
response = client.post(
|
||||
"/api/v1/inventory", headers=auth_headers, json=inventory_data
|
||||
)
|
||||
|
||||
assert response.status_code in [400, 422]
|
||||
data = response.json()
|
||||
@@ -138,7 +148,9 @@ class TestInventoryAPI:
|
||||
data = response.json()
|
||||
assert data["quantity"] == 35 # 50 - 15
|
||||
|
||||
def test_remove_inventory_insufficient_returns_business_logic_error(self, client, auth_headers, db):
|
||||
def test_remove_inventory_insufficient_returns_business_logic_error(
|
||||
self, client, auth_headers, db
|
||||
):
|
||||
"""Test removing more inventory than available returns InsufficientInventoryException"""
|
||||
# Create initial inventory
|
||||
inventory = Inventory(gtin="1234567890123", location="WAREHOUSE_A", quantity=10)
|
||||
@@ -184,7 +196,9 @@ class TestInventoryAPI:
|
||||
assert data["error_code"] == "INVENTORY_NOT_FOUND"
|
||||
assert data["status_code"] == 404
|
||||
|
||||
def test_negative_inventory_not_allowed_business_logic_error(self, client, auth_headers, db):
|
||||
def test_negative_inventory_not_allowed_business_logic_error(
|
||||
self, client, auth_headers, db
|
||||
):
|
||||
"""Test operations resulting in negative inventory returns NegativeInventoryException"""
|
||||
# Create initial inventory
|
||||
inventory = Inventory(gtin="1234567890123", location="WAREHOUSE_A", quantity=5)
|
||||
@@ -204,14 +218,21 @@ class TestInventoryAPI:
|
||||
assert response.status_code == 400
|
||||
data = response.json()
|
||||
# This might be caught as INSUFFICIENT_INVENTORY or NEGATIVE_INVENTORY_NOT_ALLOWED
|
||||
assert data["error_code"] in ["INSUFFICIENT_INVENTORY", "NEGATIVE_INVENTORY_NOT_ALLOWED"]
|
||||
assert data["error_code"] in [
|
||||
"INSUFFICIENT_INVENTORY",
|
||||
"NEGATIVE_INVENTORY_NOT_ALLOWED",
|
||||
]
|
||||
assert data["status_code"] == 400
|
||||
|
||||
def test_get_inventory_by_gtin_success(self, client, auth_headers, db):
|
||||
"""Test getting inventory summary for GTIN successfully"""
|
||||
# Create inventory in multiple locations
|
||||
inventory1 = Inventory(gtin="1234567890123", location="WAREHOUSE_A", quantity=50)
|
||||
inventory2 = Inventory(gtin="1234567890123", location="WAREHOUSE_B", quantity=25)
|
||||
inventory1 = Inventory(
|
||||
gtin="1234567890123", location="WAREHOUSE_A", quantity=50
|
||||
)
|
||||
inventory2 = Inventory(
|
||||
gtin="1234567890123", location="WAREHOUSE_B", quantity=25
|
||||
)
|
||||
db.add_all([inventory1, inventory2])
|
||||
db.commit()
|
||||
|
||||
@@ -238,12 +259,18 @@ class TestInventoryAPI:
|
||||
def test_get_total_inventory_success(self, client, auth_headers, db):
|
||||
"""Test getting total inventory for GTIN successfully"""
|
||||
# Create inventory in multiple locations
|
||||
inventory1 = Inventory(gtin="1234567890123", location="WAREHOUSE_A", quantity=50)
|
||||
inventory2 = Inventory(gtin="1234567890123", location="WAREHOUSE_B", quantity=25)
|
||||
inventory1 = Inventory(
|
||||
gtin="1234567890123", location="WAREHOUSE_A", quantity=50
|
||||
)
|
||||
inventory2 = Inventory(
|
||||
gtin="1234567890123", location="WAREHOUSE_B", quantity=25
|
||||
)
|
||||
db.add_all([inventory1, inventory2])
|
||||
db.commit()
|
||||
|
||||
response = client.get("/api/v1/inventory/1234567890123/total", headers=auth_headers)
|
||||
response = client.get(
|
||||
"/api/v1/inventory/1234567890123/total", headers=auth_headers
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
@@ -253,7 +280,9 @@ class TestInventoryAPI:
|
||||
|
||||
def test_get_total_inventory_not_found(self, client, auth_headers):
|
||||
"""Test getting total inventory for nonexistent GTIN returns InventoryNotFoundException"""
|
||||
response = client.get("/api/v1/inventory/9999999999999/total", headers=auth_headers)
|
||||
response = client.get(
|
||||
"/api/v1/inventory/9999999999999/total", headers=auth_headers
|
||||
)
|
||||
|
||||
assert response.status_code == 404
|
||||
data = response.json()
|
||||
@@ -263,8 +292,12 @@ class TestInventoryAPI:
|
||||
def test_get_all_inventory_success(self, client, auth_headers, db):
|
||||
"""Test getting all inventory entries successfully"""
|
||||
# Create some inventory entries
|
||||
inventory1 = Inventory(gtin="1234567890123", location="WAREHOUSE_A", quantity=50)
|
||||
inventory2 = Inventory(gtin="9876543210987", location="WAREHOUSE_B", quantity=25)
|
||||
inventory1 = Inventory(
|
||||
gtin="1234567890123", location="WAREHOUSE_A", quantity=50
|
||||
)
|
||||
inventory2 = Inventory(
|
||||
gtin="9876543210987", location="WAREHOUSE_B", quantity=25
|
||||
)
|
||||
db.add_all([inventory1, inventory2])
|
||||
db.commit()
|
||||
|
||||
@@ -277,20 +310,28 @@ class TestInventoryAPI:
|
||||
def test_get_all_inventory_with_filters(self, client, auth_headers, db):
|
||||
"""Test getting inventory entries with filtering"""
|
||||
# Create inventory entries
|
||||
inventory1 = Inventory(gtin="1234567890123", location="WAREHOUSE_A", quantity=50)
|
||||
inventory2 = Inventory(gtin="9876543210987", location="WAREHOUSE_B", quantity=25)
|
||||
inventory1 = Inventory(
|
||||
gtin="1234567890123", location="WAREHOUSE_A", quantity=50
|
||||
)
|
||||
inventory2 = Inventory(
|
||||
gtin="9876543210987", location="WAREHOUSE_B", quantity=25
|
||||
)
|
||||
db.add_all([inventory1, inventory2])
|
||||
db.commit()
|
||||
|
||||
# Filter by location
|
||||
response = client.get("/api/v1/inventory?location=WAREHOUSE_A", headers=auth_headers)
|
||||
response = client.get(
|
||||
"/api/v1/inventory?location=WAREHOUSE_A", headers=auth_headers
|
||||
)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
for inventory in data:
|
||||
assert inventory["location"] == "WAREHOUSE_A"
|
||||
|
||||
# Filter by GTIN
|
||||
response = client.get("/api/v1/inventory?gtin=1234567890123", headers=auth_headers)
|
||||
response = client.get(
|
||||
"/api/v1/inventory?gtin=1234567890123", headers=auth_headers
|
||||
)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
for inventory in data:
|
||||
@@ -390,7 +431,9 @@ class TestInventoryAPI:
|
||||
"quantity": 100,
|
||||
}
|
||||
|
||||
response = client.post("/api/v1/inventory", headers=auth_headers, json=inventory_data)
|
||||
response = client.post(
|
||||
"/api/v1/inventory", headers=auth_headers, json=inventory_data
|
||||
)
|
||||
|
||||
# This depends on whether your service validates locations
|
||||
if response.status_code == 404:
|
||||
|
||||
Reference in New Issue
Block a user