Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 9, 2021 12:33
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/9d9fb2e4c0cd69ab70bc0666066a92fb to your computer and use it in GitHub Desktop.
Save velotiotech/9d9fb2e4c0cd69ab70bc0666066a92fb to your computer and use it in GitHub Desktop.
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):
product = Product.objects.create(name="Book 1", category=category)
product.retails.add(retailer_abc)
return product
def test_product_retailer(db, retailer_abc, product_one):
assert product_one.retails.filter(name=retailer_abc.name).exists()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment