fix: resolve remaining Inventory.location test failures and add Grafana config fields
All checks were successful
CI / ruff (push) Successful in 11s
CI / pytest (push) Successful in 38m13s
CI / validate (push) Successful in 23s
CI / deploy (push) Successful in 51s
CI / dependency-scanning (push) Successful in 33s
CI / docs (push) Successful in 41s

- 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:
2026-02-15 13:44:44 +01:00
parent aad18c27ab
commit 10aa75aa69
3 changed files with 19 additions and 21 deletions

View File

@@ -107,7 +107,7 @@ class TestInventoryService:
assert result.product_id == test_product.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
def test_set_inventory_existing_entry_replaces(
@@ -116,7 +116,7 @@ class TestInventoryService:
"""Test setting inventory replaces existing quantity."""
inventory_data = InventoryCreate(
product_id=test_product.id,
location=test_inventory.location,
location=test_inventory.bin_location,
quantity=200,
)
@@ -175,7 +175,7 @@ class TestInventoryService:
inventory_data = InventoryAdjust(
product_id=test_product.id,
location=test_inventory.location,
location=test_inventory.bin_location,
quantity=25,
)
@@ -191,7 +191,7 @@ class TestInventoryService:
inventory_data = InventoryAdjust(
product_id=test_product.id,
location=test_inventory.location,
location=test_inventory.bin_location,
quantity=-10,
)
@@ -207,7 +207,7 @@ class TestInventoryService:
inventory_data = InventoryAdjust(
product_id=test_product.id,
location=test_inventory.location,
location=test_inventory.bin_location,
quantity=-(test_inventory.quantity + 100), # More than available
)
@@ -239,7 +239,7 @@ class TestInventoryService:
reserve_data = InventoryReserve(
product_id=test_product.id,
location=test_inventory.location,
location=test_inventory.bin_location,
quantity=reserve_qty,
)
@@ -257,7 +257,7 @@ class TestInventoryService:
reserve_data = InventoryReserve(
product_id=test_product.id,
location=test_inventory.location,
location=test_inventory.bin_location,
quantity=available + 100, # More than available
)
@@ -288,7 +288,7 @@ class TestInventoryService:
reserve_data = InventoryReserve(
product_id=test_product.id,
location=test_inventory.location,
location=test_inventory.bin_location,
quantity=release_qty,
)
@@ -302,7 +302,7 @@ class TestInventoryService:
"""Test releasing more than reserved sets to zero (doesn't error)."""
reserve_data = InventoryReserve(
product_id=test_product.id,
location=test_inventory.location,
location=test_inventory.bin_location,
quantity=test_inventory.reserved_quantity + 100,
)
@@ -322,7 +322,7 @@ class TestInventoryService:
reserve_data = InventoryReserve(
product_id=test_product.id,
location=test_inventory.location,
location=test_inventory.bin_location,
quantity=fulfill_qty,
)
@@ -339,7 +339,7 @@ class TestInventoryService:
reserve_data = InventoryReserve(
product_id=test_product.id,
location=test_inventory.location,
location=test_inventory.bin_location,
quantity=test_inventory.quantity + 100,
)
@@ -423,12 +423,12 @@ class TestInventoryService:
):
"""Test getting store inventory filtered by location."""
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
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):
"""Test getting store inventory filtered by low stock threshold."""
@@ -477,7 +477,7 @@ class TestInventoryService:
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):
"""Test updating non-existent inventory raises InventoryNotFoundException."""
@@ -570,7 +570,7 @@ class TestInventoryService:
self, db, test_inventory
):
"""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(
db, location=location_prefix
)
@@ -614,7 +614,6 @@ class TestInventoryService:
store_id=test_store.id,
warehouse="strassen",
bin_location=f"LOW_{unique_id}",
location=f"LOW_{unique_id}",
quantity=3,
reserved_quantity=0,
)
@@ -650,7 +649,7 @@ class TestInventoryService:
result = self.service.get_inventory_locations_admin(db)
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(
self, db, test_inventory, test_store
@@ -760,7 +759,7 @@ class TestInventoryService:
):
"""Test _get_inventory_entry returns existing 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