fix: resolve remaining Inventory.location test failures and add Grafana config fields
All checks were successful
All checks were successful
- Fix test_inventory_service.py: replace model .location with .bin_location - Fix test_product_model.py: remove location= from Inventory constructors - Add grafana_admin_user/password to Settings for production Grafana config Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -199,6 +199,8 @@ class Settings(BaseSettings):
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
enable_metrics: bool = False
|
enable_metrics: bool = False
|
||||||
grafana_url: str = "https://grafana.wizard.lu"
|
grafana_url: str = "https://grafana.wizard.lu"
|
||||||
|
grafana_admin_user: str = "admin"
|
||||||
|
grafana_admin_password: str = ""
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# CLOUDFLARE R2 STORAGE
|
# CLOUDFLARE R2 STORAGE
|
||||||
|
|||||||
@@ -324,7 +324,6 @@ class TestProductInventoryProperties:
|
|||||||
store_id=test_store.id,
|
store_id=test_store.id,
|
||||||
warehouse="strassen",
|
warehouse="strassen",
|
||||||
bin_location="SA-01-01",
|
bin_location="SA-01-01",
|
||||||
location="WAREHOUSE_A",
|
|
||||||
quantity=100,
|
quantity=100,
|
||||||
reserved_quantity=10,
|
reserved_quantity=10,
|
||||||
)
|
)
|
||||||
@@ -333,7 +332,6 @@ class TestProductInventoryProperties:
|
|||||||
store_id=test_store.id,
|
store_id=test_store.id,
|
||||||
warehouse="strassen",
|
warehouse="strassen",
|
||||||
bin_location="SA-01-02",
|
bin_location="SA-01-02",
|
||||||
location="WAREHOUSE_B",
|
|
||||||
quantity=50,
|
quantity=50,
|
||||||
reserved_quantity=5,
|
reserved_quantity=5,
|
||||||
)
|
)
|
||||||
@@ -382,7 +380,6 @@ class TestProductInventoryProperties:
|
|||||||
store_id=test_store.id,
|
store_id=test_store.id,
|
||||||
warehouse="strassen",
|
warehouse="strassen",
|
||||||
bin_location="DIG-01-01",
|
bin_location="DIG-01-01",
|
||||||
location="DIGITAL_LICENSES",
|
|
||||||
quantity=10,
|
quantity=10,
|
||||||
reserved_quantity=2,
|
reserved_quantity=2,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class TestInventoryService:
|
|||||||
|
|
||||||
assert result.product_id == test_product.id
|
assert result.product_id == test_product.id
|
||||||
assert result.store_id == test_store.id
|
assert result.store_id == test_store.id
|
||||||
assert result.location == f"WAREHOUSE_NEW_{unique_id}"
|
assert result.bin_location == f"WAREHOUSE_NEW_{unique_id}"
|
||||||
assert result.quantity == 100
|
assert result.quantity == 100
|
||||||
|
|
||||||
def test_set_inventory_existing_entry_replaces(
|
def test_set_inventory_existing_entry_replaces(
|
||||||
@@ -116,7 +116,7 @@ class TestInventoryService:
|
|||||||
"""Test setting inventory replaces existing quantity."""
|
"""Test setting inventory replaces existing quantity."""
|
||||||
inventory_data = InventoryCreate(
|
inventory_data = InventoryCreate(
|
||||||
product_id=test_product.id,
|
product_id=test_product.id,
|
||||||
location=test_inventory.location,
|
location=test_inventory.bin_location,
|
||||||
quantity=200,
|
quantity=200,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ class TestInventoryService:
|
|||||||
|
|
||||||
inventory_data = InventoryAdjust(
|
inventory_data = InventoryAdjust(
|
||||||
product_id=test_product.id,
|
product_id=test_product.id,
|
||||||
location=test_inventory.location,
|
location=test_inventory.bin_location,
|
||||||
quantity=25,
|
quantity=25,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ class TestInventoryService:
|
|||||||
|
|
||||||
inventory_data = InventoryAdjust(
|
inventory_data = InventoryAdjust(
|
||||||
product_id=test_product.id,
|
product_id=test_product.id,
|
||||||
location=test_inventory.location,
|
location=test_inventory.bin_location,
|
||||||
quantity=-10,
|
quantity=-10,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ class TestInventoryService:
|
|||||||
|
|
||||||
inventory_data = InventoryAdjust(
|
inventory_data = InventoryAdjust(
|
||||||
product_id=test_product.id,
|
product_id=test_product.id,
|
||||||
location=test_inventory.location,
|
location=test_inventory.bin_location,
|
||||||
quantity=-(test_inventory.quantity + 100), # More than available
|
quantity=-(test_inventory.quantity + 100), # More than available
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ class TestInventoryService:
|
|||||||
|
|
||||||
reserve_data = InventoryReserve(
|
reserve_data = InventoryReserve(
|
||||||
product_id=test_product.id,
|
product_id=test_product.id,
|
||||||
location=test_inventory.location,
|
location=test_inventory.bin_location,
|
||||||
quantity=reserve_qty,
|
quantity=reserve_qty,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -257,7 +257,7 @@ class TestInventoryService:
|
|||||||
|
|
||||||
reserve_data = InventoryReserve(
|
reserve_data = InventoryReserve(
|
||||||
product_id=test_product.id,
|
product_id=test_product.id,
|
||||||
location=test_inventory.location,
|
location=test_inventory.bin_location,
|
||||||
quantity=available + 100, # More than available
|
quantity=available + 100, # More than available
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -288,7 +288,7 @@ class TestInventoryService:
|
|||||||
|
|
||||||
reserve_data = InventoryReserve(
|
reserve_data = InventoryReserve(
|
||||||
product_id=test_product.id,
|
product_id=test_product.id,
|
||||||
location=test_inventory.location,
|
location=test_inventory.bin_location,
|
||||||
quantity=release_qty,
|
quantity=release_qty,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ class TestInventoryService:
|
|||||||
"""Test releasing more than reserved sets to zero (doesn't error)."""
|
"""Test releasing more than reserved sets to zero (doesn't error)."""
|
||||||
reserve_data = InventoryReserve(
|
reserve_data = InventoryReserve(
|
||||||
product_id=test_product.id,
|
product_id=test_product.id,
|
||||||
location=test_inventory.location,
|
location=test_inventory.bin_location,
|
||||||
quantity=test_inventory.reserved_quantity + 100,
|
quantity=test_inventory.reserved_quantity + 100,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -322,7 +322,7 @@ class TestInventoryService:
|
|||||||
|
|
||||||
reserve_data = InventoryReserve(
|
reserve_data = InventoryReserve(
|
||||||
product_id=test_product.id,
|
product_id=test_product.id,
|
||||||
location=test_inventory.location,
|
location=test_inventory.bin_location,
|
||||||
quantity=fulfill_qty,
|
quantity=fulfill_qty,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -339,7 +339,7 @@ class TestInventoryService:
|
|||||||
|
|
||||||
reserve_data = InventoryReserve(
|
reserve_data = InventoryReserve(
|
||||||
product_id=test_product.id,
|
product_id=test_product.id,
|
||||||
location=test_inventory.location,
|
location=test_inventory.bin_location,
|
||||||
quantity=test_inventory.quantity + 100,
|
quantity=test_inventory.quantity + 100,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -423,12 +423,12 @@ class TestInventoryService:
|
|||||||
):
|
):
|
||||||
"""Test getting store inventory filtered by location."""
|
"""Test getting store inventory filtered by location."""
|
||||||
result = self.service.get_store_inventory(
|
result = self.service.get_store_inventory(
|
||||||
db, test_store.id, location=test_inventory.location[:10]
|
db, test_store.id, location=test_inventory.bin_location[:10]
|
||||||
)
|
)
|
||||||
|
|
||||||
assert len(result) >= 1
|
assert len(result) >= 1
|
||||||
for inv in result:
|
for inv in result:
|
||||||
assert test_inventory.location[:10].upper() in inv.location.upper()
|
assert test_inventory.bin_location[:10].upper() in inv.bin_location.upper()
|
||||||
|
|
||||||
def test_get_store_inventory_with_low_stock_filter(self, db, test_store):
|
def test_get_store_inventory_with_low_stock_filter(self, db, test_store):
|
||||||
"""Test getting store inventory filtered by low stock threshold."""
|
"""Test getting store inventory filtered by low stock threshold."""
|
||||||
@@ -477,7 +477,7 @@ class TestInventoryService:
|
|||||||
db, test_store.id, test_inventory.id, inventory_update
|
db, test_store.id, test_inventory.id, inventory_update
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.location == new_location.upper()
|
assert result.bin_location == new_location.upper()
|
||||||
|
|
||||||
def test_update_inventory_not_found(self, db, test_store):
|
def test_update_inventory_not_found(self, db, test_store):
|
||||||
"""Test updating non-existent inventory raises InventoryNotFoundException."""
|
"""Test updating non-existent inventory raises InventoryNotFoundException."""
|
||||||
@@ -570,7 +570,7 @@ class TestInventoryService:
|
|||||||
self, db, test_inventory
|
self, db, test_inventory
|
||||||
):
|
):
|
||||||
"""Test get_all_inventory_admin filters by location."""
|
"""Test get_all_inventory_admin filters by location."""
|
||||||
location_prefix = test_inventory.location[:5]
|
location_prefix = test_inventory.bin_location[:5]
|
||||||
result = self.service.get_all_inventory_admin(
|
result = self.service.get_all_inventory_admin(
|
||||||
db, location=location_prefix
|
db, location=location_prefix
|
||||||
)
|
)
|
||||||
@@ -614,7 +614,6 @@ class TestInventoryService:
|
|||||||
store_id=test_store.id,
|
store_id=test_store.id,
|
||||||
warehouse="strassen",
|
warehouse="strassen",
|
||||||
bin_location=f"LOW_{unique_id}",
|
bin_location=f"LOW_{unique_id}",
|
||||||
location=f"LOW_{unique_id}",
|
|
||||||
quantity=3,
|
quantity=3,
|
||||||
reserved_quantity=0,
|
reserved_quantity=0,
|
||||||
)
|
)
|
||||||
@@ -650,7 +649,7 @@ class TestInventoryService:
|
|||||||
result = self.service.get_inventory_locations_admin(db)
|
result = self.service.get_inventory_locations_admin(db)
|
||||||
|
|
||||||
assert len(result.locations) >= 1
|
assert len(result.locations) >= 1
|
||||||
assert test_inventory.location in result.locations
|
assert test_inventory.bin_location in result.locations
|
||||||
|
|
||||||
def test_get_inventory_locations_admin_with_store_filter(
|
def test_get_inventory_locations_admin_with_store_filter(
|
||||||
self, db, test_inventory, test_store
|
self, db, test_inventory, test_store
|
||||||
@@ -760,7 +759,7 @@ class TestInventoryService:
|
|||||||
):
|
):
|
||||||
"""Test _get_inventory_entry returns existing entry."""
|
"""Test _get_inventory_entry returns existing entry."""
|
||||||
result = self.service._get_inventory_entry(
|
result = self.service._get_inventory_entry(
|
||||||
db, test_product.id, test_inventory.location
|
db, test_product.id, test_inventory.bin_location
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result is not None
|
assert result is not None
|
||||||
|
|||||||
Reference in New Issue
Block a user