shop product refactoring
This commit is contained in:
25
tests/fixtures/shop_fixtures.py
vendored
25
tests/fixtures/shop_fixtures.py
vendored
@@ -3,7 +3,8 @@ import uuid
|
||||
|
||||
import pytest
|
||||
|
||||
from models.database.shop import Shop, ShopProduct
|
||||
from models.database.shop import Shop
|
||||
from models.database.product import Product
|
||||
from models.database.stock import Stock
|
||||
|
||||
|
||||
@@ -77,23 +78,23 @@ def verified_shop(db, other_user):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def shop_product(db, test_shop, unique_product):
|
||||
def test_product(db, test_shop, unique_product):
|
||||
"""Create a shop product relationship"""
|
||||
shop_product = ShopProduct(
|
||||
product = Product(
|
||||
shop_id=test_shop.id, marketplace_product_id=unique_product.id, is_active=True
|
||||
)
|
||||
# Add optional fields if they exist in your model
|
||||
if hasattr(ShopProduct, "shop_price"):
|
||||
shop_product.shop_price = 24.99
|
||||
if hasattr(ShopProduct, "is_featured"):
|
||||
shop_product.is_featured = False
|
||||
if hasattr(ShopProduct, "min_quantity"):
|
||||
shop_product.min_quantity = 1
|
||||
if hasattr(Product, "shop_price"):
|
||||
product.price = 24.99
|
||||
if hasattr(Product, "is_featured"):
|
||||
product.is_featured = False
|
||||
if hasattr(Product, "min_quantity"):
|
||||
product.min_quantity = 1
|
||||
|
||||
db.add(shop_product)
|
||||
db.add(product)
|
||||
db.commit()
|
||||
db.refresh(shop_product)
|
||||
return shop_product
|
||||
db.refresh(product)
|
||||
return product
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
4
tests/fixtures/testing_fixtures.py
vendored
4
tests/fixtures/testing_fixtures.py
vendored
@@ -22,9 +22,9 @@ def empty_db(db):
|
||||
# In order to respect foreign key constraints
|
||||
tables_to_clear = [
|
||||
"marketplace_import_jobs", # Has foreign keys to shops and users
|
||||
"shop_products", # Has foreign keys to shops and products
|
||||
"products", # Has foreign keys to shops and products
|
||||
"stock", # Fixed: singular not plural
|
||||
"products", # Referenced by shop_products
|
||||
"products", # Referenced by products
|
||||
"shops", # Has foreign key to users
|
||||
"users" # Base table
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user