code quality run
This commit is contained in:
@@ -40,7 +40,7 @@ class TestStatsService:
|
||||
marketplace="Amazon",
|
||||
shop_name="AmazonShop",
|
||||
price="15.99",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
),
|
||||
Product(
|
||||
product_id="PROD003",
|
||||
@@ -50,7 +50,7 @@ class TestStatsService:
|
||||
marketplace="eBay",
|
||||
shop_name="eBayShop",
|
||||
price="25.99",
|
||||
currency="USD"
|
||||
currency="USD",
|
||||
),
|
||||
Product(
|
||||
product_id="PROD004",
|
||||
@@ -60,8 +60,8 @@ class TestStatsService:
|
||||
marketplace="Letzshop", # Same as test_product
|
||||
shop_name="DifferentShop",
|
||||
price="35.99",
|
||||
currency="EUR"
|
||||
)
|
||||
currency="EUR",
|
||||
),
|
||||
]
|
||||
db.add_all(additional_products)
|
||||
db.commit()
|
||||
@@ -86,7 +86,7 @@ class TestStatsService:
|
||||
marketplace=None, # Null marketplace
|
||||
shop_name=None, # Null shop
|
||||
price="10.00",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
),
|
||||
Product(
|
||||
product_id="EMPTY001",
|
||||
@@ -96,8 +96,8 @@ class TestStatsService:
|
||||
marketplace="", # Empty marketplace
|
||||
shop_name="", # Empty shop
|
||||
price="15.00",
|
||||
currency="EUR"
|
||||
)
|
||||
currency="EUR",
|
||||
),
|
||||
]
|
||||
db.add_all(products_with_nulls)
|
||||
db.commit()
|
||||
@@ -122,14 +122,16 @@ class TestStatsService:
|
||||
# Find our test marketplace in the results
|
||||
test_marketplace_stat = next(
|
||||
(stat for stat in stats if stat["marketplace"] == test_product.marketplace),
|
||||
None
|
||||
None,
|
||||
)
|
||||
assert test_marketplace_stat is not None
|
||||
assert test_marketplace_stat["total_products"] >= 1
|
||||
assert test_marketplace_stat["unique_shops"] >= 1
|
||||
assert test_marketplace_stat["unique_brands"] >= 1
|
||||
|
||||
def test_get_marketplace_breakdown_stats_multiple_marketplaces(self, db, test_product):
|
||||
def test_get_marketplace_breakdown_stats_multiple_marketplaces(
|
||||
self, db, test_product
|
||||
):
|
||||
"""Test marketplace breakdown with multiple marketplaces"""
|
||||
# Create products for different marketplaces
|
||||
marketplace_products = [
|
||||
@@ -140,7 +142,7 @@ class TestStatsService:
|
||||
marketplace="Amazon",
|
||||
shop_name="AmazonShop1",
|
||||
price="20.00",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
),
|
||||
Product(
|
||||
product_id="AMAZON002",
|
||||
@@ -149,7 +151,7 @@ class TestStatsService:
|
||||
marketplace="Amazon",
|
||||
shop_name="AmazonShop2",
|
||||
price="25.00",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
),
|
||||
Product(
|
||||
product_id="EBAY001",
|
||||
@@ -158,8 +160,8 @@ class TestStatsService:
|
||||
marketplace="eBay",
|
||||
shop_name="eBayShop",
|
||||
price="30.00",
|
||||
currency="USD"
|
||||
)
|
||||
currency="USD",
|
||||
),
|
||||
]
|
||||
db.add_all(marketplace_products)
|
||||
db.commit()
|
||||
@@ -194,7 +196,7 @@ class TestStatsService:
|
||||
shop_name="SomeShop",
|
||||
brand="SomeBrand",
|
||||
price="10.00",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
)
|
||||
db.add(null_marketplace_product)
|
||||
db.commit()
|
||||
@@ -202,7 +204,9 @@ class TestStatsService:
|
||||
stats = self.service.get_marketplace_breakdown_stats(db)
|
||||
|
||||
# Should not include any stats for null marketplace
|
||||
marketplace_names = [stat["marketplace"] for stat in stats if stat["marketplace"] is not None]
|
||||
marketplace_names = [
|
||||
stat["marketplace"] for stat in stats if stat["marketplace"] is not None
|
||||
]
|
||||
assert None not in marketplace_names
|
||||
|
||||
def test_get_product_count(self, db, test_product):
|
||||
@@ -223,7 +227,7 @@ class TestStatsService:
|
||||
marketplace="Test",
|
||||
shop_name="TestShop",
|
||||
price="10.00",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
),
|
||||
Product(
|
||||
product_id="BRAND002",
|
||||
@@ -232,15 +236,17 @@ class TestStatsService:
|
||||
marketplace="Test",
|
||||
shop_name="TestShop",
|
||||
price="15.00",
|
||||
currency="EUR"
|
||||
)
|
||||
currency="EUR",
|
||||
),
|
||||
]
|
||||
db.add_all(brand_products)
|
||||
db.commit()
|
||||
|
||||
count = self.service.get_unique_brands_count(db)
|
||||
|
||||
assert count >= 2 # At least BrandA and BrandB, plus possibly test_product brand
|
||||
assert (
|
||||
count >= 2
|
||||
) # At least BrandA and BrandB, plus possibly test_product brand
|
||||
assert isinstance(count, int)
|
||||
|
||||
def test_get_unique_categories_count(self, db, test_product):
|
||||
@@ -254,7 +260,7 @@ class TestStatsService:
|
||||
marketplace="Test",
|
||||
shop_name="TestShop",
|
||||
price="10.00",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
),
|
||||
Product(
|
||||
product_id="CAT002",
|
||||
@@ -263,8 +269,8 @@ class TestStatsService:
|
||||
marketplace="Test",
|
||||
shop_name="TestShop",
|
||||
price="15.00",
|
||||
currency="EUR"
|
||||
)
|
||||
currency="EUR",
|
||||
),
|
||||
]
|
||||
db.add_all(category_products)
|
||||
db.commit()
|
||||
@@ -284,7 +290,7 @@ class TestStatsService:
|
||||
marketplace="Amazon",
|
||||
shop_name="AmazonShop",
|
||||
price="10.00",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
),
|
||||
Product(
|
||||
product_id="MARKET002",
|
||||
@@ -292,8 +298,8 @@ class TestStatsService:
|
||||
marketplace="eBay",
|
||||
shop_name="eBayShop",
|
||||
price="15.00",
|
||||
currency="EUR"
|
||||
)
|
||||
currency="EUR",
|
||||
),
|
||||
]
|
||||
db.add_all(marketplace_products)
|
||||
db.commit()
|
||||
@@ -313,7 +319,7 @@ class TestStatsService:
|
||||
marketplace="Test",
|
||||
shop_name="ShopA",
|
||||
price="10.00",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
),
|
||||
Product(
|
||||
product_id="SHOP002",
|
||||
@@ -321,8 +327,8 @@ class TestStatsService:
|
||||
marketplace="Test",
|
||||
shop_name="ShopB",
|
||||
price="15.00",
|
||||
currency="EUR"
|
||||
)
|
||||
currency="EUR",
|
||||
),
|
||||
]
|
||||
db.add_all(shop_products)
|
||||
db.commit()
|
||||
@@ -341,15 +347,15 @@ class TestStatsService:
|
||||
location="LOCATION2",
|
||||
quantity=25,
|
||||
reserved_quantity=5,
|
||||
shop_id=test_stock.shop_id
|
||||
shop_id=test_stock.shop_id,
|
||||
),
|
||||
Stock(
|
||||
gtin="1234567890125",
|
||||
location="LOCATION3",
|
||||
quantity=0, # Out of stock
|
||||
reserved_quantity=0,
|
||||
shop_id=test_stock.shop_id
|
||||
)
|
||||
shop_id=test_stock.shop_id,
|
||||
),
|
||||
]
|
||||
db.add_all(additional_stocks)
|
||||
db.commit()
|
||||
@@ -372,7 +378,7 @@ class TestStatsService:
|
||||
marketplace="SpecificMarket",
|
||||
shop_name="SpecificShop1",
|
||||
price="10.00",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
),
|
||||
Product(
|
||||
product_id="SPECIFIC002",
|
||||
@@ -381,7 +387,7 @@ class TestStatsService:
|
||||
marketplace="SpecificMarket",
|
||||
shop_name="SpecificShop2",
|
||||
price="15.00",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
),
|
||||
Product(
|
||||
product_id="OTHER001",
|
||||
@@ -390,8 +396,8 @@ class TestStatsService:
|
||||
marketplace="OtherMarket",
|
||||
shop_name="OtherShop",
|
||||
price="20.00",
|
||||
currency="EUR"
|
||||
)
|
||||
currency="EUR",
|
||||
),
|
||||
]
|
||||
db.add_all(marketplace_products)
|
||||
db.commit()
|
||||
@@ -414,7 +420,7 @@ class TestStatsService:
|
||||
marketplace="TestMarketplace",
|
||||
shop_name="TestShop1",
|
||||
price="10.00",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
),
|
||||
Product(
|
||||
product_id="SHOPTEST002",
|
||||
@@ -423,8 +429,8 @@ class TestStatsService:
|
||||
marketplace="TestMarketplace",
|
||||
shop_name="TestShop2",
|
||||
price="15.00",
|
||||
currency="EUR"
|
||||
)
|
||||
currency="EUR",
|
||||
),
|
||||
]
|
||||
db.add_all(marketplace_products)
|
||||
db.commit()
|
||||
@@ -445,7 +451,7 @@ class TestStatsService:
|
||||
marketplace="CountMarketplace",
|
||||
shop_name="CountShop",
|
||||
price="10.00",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
),
|
||||
Product(
|
||||
product_id="COUNT002",
|
||||
@@ -453,7 +459,7 @@ class TestStatsService:
|
||||
marketplace="CountMarketplace",
|
||||
shop_name="CountShop",
|
||||
price="15.00",
|
||||
currency="EUR"
|
||||
currency="EUR",
|
||||
),
|
||||
Product(
|
||||
product_id="COUNT003",
|
||||
@@ -461,8 +467,8 @@ class TestStatsService:
|
||||
marketplace="CountMarketplace",
|
||||
shop_name="CountShop",
|
||||
price="20.00",
|
||||
currency="EUR"
|
||||
)
|
||||
currency="EUR",
|
||||
),
|
||||
]
|
||||
db.add_all(marketplace_products)
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user