Created
June 9, 2021 12:33
-
-
Save velotiotech/9d9fb2e4c0cd69ab70bc0666066a92fb 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 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