Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 9, 2021 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/43d147781b0e90530ec59abd6c6ecf68 to your computer and use it in GitHub Desktop.
Save velotiotech/43d147781b0e90530ec59abd6c6ecf68 to your computer and use it in GitHub Desktop.
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