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 pytest | |
from product.models import Category, Product, Retail | |
... | |
@pytest.fixture | |
def retailer_abc(db): | |
return Retail.objects.create(name="ABC") | |
@pytest.fixture | |
def retailers(db) -> list: | |
return [] | |
@pytest.fixture(autouse=True) | |
def append_retailers(retailers, retailer_abc): | |
return retailers.append(retailer_abc) | |
@pytest.fixture | |
def product_one(db, category, retailers): | |
product = Product.objects.create(name="Book 1", category=category) | |
product.retails.set(retailers) | |
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