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

@@ -3,7 +3,7 @@ import pytest
from app.services.stats_service import StatsService
from models.database.marketplace_product import MarketplaceProduct
from models.database.stock import Stock
from models.database.inventory import Inventory
@pytest.mark.unit
@@ -15,7 +15,7 @@ class TestStatsService:
"""Setup method following the same pattern as other service tests"""
self.service = StatsService()
def test_get_comprehensive_stats_basic(self, db, test_marketplace_product, test_stock):
def test_get_comprehensive_stats_basic(self, db, test_marketplace_product, test_inventory):
"""Test getting comprehensive stats with basic data"""
stats = self.service.get_comprehensive_stats(db)
@@ -24,12 +24,12 @@ class TestStatsService:
assert "unique_categories" in stats
assert "unique_marketplaces" in stats
assert "unique_vendors" in stats
assert "total_stock_entries" in stats
assert "total_inventory_entries" in stats
assert "total_inventory_quantity" in stats
assert stats["total_products"] >= 1
assert stats["total_stock_entries"] >= 1
assert stats["total_inventory_quantity"] >= 10 # test_stock has quantity 10
assert stats["total_inventory_entries"] >= 1
assert stats["total_inventory_quantity"] >= 10 # test_inventory has quantity 10
def test_get_comprehensive_stats_multiple_products(self, db, test_marketplace_product):
"""Test comprehensive stats with multiple products across different dimensions"""
@@ -341,33 +341,33 @@ class TestStatsService:
assert count >= 2 # At least VendorA and VendorB, plus test_marketplace_product vendor
assert isinstance(count, int)
def test_get_stock_statistics(self, db, test_stock):
"""Test getting stock statistics"""
# Add additional stock entries
additional_stocks = [
Stock(
def test_get_inventory_statistics(self, db, test_inventory):
"""Test getting inventory statistics"""
# Add additional inventory entries
additional_inventory = [
Inventory(
gtin="1234567890124",
location="LOCATION2",
quantity=25,
reserved_quantity=5,
vendor_id=test_stock.vendor_id,
vendor_id=test_inventory.vendor_id,
),
Stock(
Inventory(
gtin="1234567890125",
location="LOCATION3",
quantity=0, # Out of stock
quantity=0, # Out of inventory
reserved_quantity=0,
vendor_id=test_stock.vendor_id,
vendor_id=test_inventory.vendor_id,
),
]
db.add_all(additional_stocks)
db.add_all(additional_inventory)
db.commit()
stats = self.service.get_stock_statistics(db)
stats = self.service.get_inventory_statistics(db)
assert "total_stock_entries" in stats
assert "total_inventory_entries" in stats
assert "total_inventory_quantity" in stats
assert stats["total_stock_entries"] >= 3 # test_stock + 2 additional
assert stats["total_inventory_entries"] >= 3 # test_inventory + 2 additional
assert stats["total_inventory_quantity"] >= 35 # 10 + 25 + 0 = 35
def test_get_brands_by_marketplace(self, db):
@@ -495,7 +495,7 @@ class TestStatsService:
assert stats["unique_categories"] == 0
assert stats["unique_marketplaces"] == 0
assert stats["unique_vendors"] == 0
assert stats["total_stock_entries"] == 0
assert stats["total_inventory_entries"] == 0
assert stats["total_inventory_quantity"] == 0
def test_marketplace_breakdown_empty_database(self, db):