code quality run
This commit is contained in:
@@ -18,7 +18,7 @@ class TestShopService:
|
||||
shop_data = ShopCreate(
|
||||
shop_code="NEWSHOP",
|
||||
shop_name="New Test Shop",
|
||||
description="A new test shop"
|
||||
description="A new test shop",
|
||||
)
|
||||
|
||||
shop = self.service.create_shop(db, shop_data, test_user)
|
||||
@@ -30,10 +30,7 @@ class TestShopService:
|
||||
|
||||
def test_create_shop_admin_auto_verify(self, db, test_admin, shop_factory):
|
||||
"""Test admin creates verified shop automatically"""
|
||||
shop_data = ShopCreate(
|
||||
shop_code="ADMINSHOP",
|
||||
shop_name="Admin Test Shop"
|
||||
)
|
||||
shop_data = ShopCreate(shop_code="ADMINSHOP", shop_name="Admin Test Shop")
|
||||
|
||||
shop = self.service.create_shop(db, shop_data, test_admin)
|
||||
|
||||
@@ -42,8 +39,7 @@ class TestShopService:
|
||||
def test_create_shop_duplicate_code(self, db, test_user, test_shop):
|
||||
"""Test shop creation fails with duplicate shop code"""
|
||||
shop_data = ShopCreate(
|
||||
shop_code=test_shop.shop_code,
|
||||
shop_name=test_shop.shop_name
|
||||
shop_code=test_shop.shop_code, shop_name=test_shop.shop_name
|
||||
)
|
||||
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
@@ -60,9 +56,13 @@ class TestShopService:
|
||||
assert test_shop.shop_code in shop_codes
|
||||
assert inactive_shop.shop_code not in shop_codes
|
||||
|
||||
def test_get_shops_admin_user(self, db, test_admin, test_shop, inactive_shop, verified_shop):
|
||||
def test_get_shops_admin_user(
|
||||
self, db, test_admin, test_shop, inactive_shop, verified_shop
|
||||
):
|
||||
"""Test admin user can see all shops with filters"""
|
||||
shops, total = self.service.get_shops(db, test_admin, active_only=False, verified_only=False)
|
||||
shops, total = self.service.get_shops(
|
||||
db, test_admin, active_only=False, verified_only=False
|
||||
)
|
||||
|
||||
shop_codes = [shop.shop_code for shop in shops]
|
||||
assert test_shop.shop_code in shop_codes
|
||||
@@ -78,7 +78,9 @@ class TestShopService:
|
||||
|
||||
def test_get_shop_by_code_admin_access(self, db, test_admin, test_shop):
|
||||
"""Test admin can access any shop"""
|
||||
shop = self.service.get_shop_by_code(db, test_shop.shop_code.lower(), test_admin)
|
||||
shop = self.service.get_shop_by_code(
|
||||
db, test_shop.shop_code.lower(), test_admin
|
||||
)
|
||||
|
||||
assert shop is not None
|
||||
assert shop.id == test_shop.id
|
||||
@@ -103,10 +105,12 @@ class TestShopService:
|
||||
product_id=unique_product.product_id,
|
||||
price="15.99",
|
||||
is_featured=True,
|
||||
stock_quantity=5
|
||||
stock_quantity=5,
|
||||
)
|
||||
|
||||
shop_product = self.service.add_product_to_shop(db, test_shop, shop_product_data)
|
||||
shop_product = self.service.add_product_to_shop(
|
||||
db, test_shop, shop_product_data
|
||||
)
|
||||
|
||||
assert shop_product is not None
|
||||
assert shop_product.shop_id == test_shop.id
|
||||
@@ -114,10 +118,7 @@ class TestShopService:
|
||||
|
||||
def test_add_product_to_shop_product_not_found(self, db, test_shop):
|
||||
"""Test adding non-existent product to shop fails"""
|
||||
shop_product_data = ShopProductCreate(
|
||||
product_id="NONEXISTENT",
|
||||
price="15.99"
|
||||
)
|
||||
shop_product_data = ShopProductCreate(product_id="NONEXISTENT", price="15.99")
|
||||
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
self.service.add_product_to_shop(db, test_shop, shop_product_data)
|
||||
@@ -127,8 +128,7 @@ class TestShopService:
|
||||
def test_add_product_to_shop_already_exists(self, db, test_shop, shop_product):
|
||||
"""Test adding product that's already in shop fails"""
|
||||
shop_product_data = ShopProductCreate(
|
||||
product_id=shop_product.product.product_id,
|
||||
price="15.99"
|
||||
product_id=shop_product.product.product_id, price="15.99"
|
||||
)
|
||||
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
@@ -136,7 +136,9 @@ class TestShopService:
|
||||
|
||||
assert exc_info.value.status_code == 400
|
||||
|
||||
def test_get_shop_products_owner_access(self, db, test_user, test_shop, shop_product):
|
||||
def test_get_shop_products_owner_access(
|
||||
self, db, test_user, test_shop, shop_product
|
||||
):
|
||||
"""Test shop owner can get shop products"""
|
||||
products, total = self.service.get_shop_products(db, test_shop, test_user)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user