Created
June 9, 2021 12:34
-
-
Save velotiotech/43d147781b0e90530ec59abd6c6ecf68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import string | |
import pytest | |
from product.models import Category, Product, Retail | |
@pytest.fixture | |
def category(db) -> Category: | |
return Category.objects.create(name="Books") | |
@pytest.fixture | |
def retailer_abc(db): | |
return Retail.objects.create(name="ABC") | |
@pytest.fixture | |
def product_one(db, category, retailer_abc): | |
sku = "".join(random.choices(string.ascii_uppercase + string.digits, k=6)) | |
product = Product.objects.create( | |
sku=sku, | |
name="Book 1", | |
description="A book for educational purpose.", | |
mrp="100.00", | |
is_available=True, | |
category=category, | |
) | |
product.retails.set([retailer_abc]) | |
return product | |
@pytest.fixture | |
def product_two(db, category, retailer): | |
sku = "".join(random.choices(string.ascii_uppercase + string.digits, k=6)) | |
product = Product.objects.create( | |
sku=sku, | |
name="Book 2", | |
description="A book with thriller story.", | |
mrp="50.00", | |
is_available=True, | |
category=category, | |
) | |
product.retails.add([retailer]) | |
return product |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment