diff --git a/src/purchase/tests/factories.py b/src/purchase/tests/factories.py index 4c641e0..1419bfe 100644 --- a/src/purchase/tests/factories.py +++ b/src/purchase/tests/factories.py @@ -40,7 +40,7 @@ class ProductFactory(factory.django.DjangoModelFactory): name = factory.Faker("text", max_nb_chars=80) unit_price_cents = factory.LazyFunction(partial(random.randint, 80, 650)) - category = factory.Iterator(ProductCategory.objects.all()) + category = factory.SubFactory(ProductCategoryFactory) class PaymentMethodFactory(factory.django.DjangoModelFactory): @@ -54,7 +54,7 @@ class BasketWithItemsFactory(factory.django.DjangoModelFactory): class Meta: model = Basket - payment_method = factory.Iterator(PaymentMethod.objects.all()) + payment_method = factory.SubFactory(PaymentMethodFactory) @factory.post_generation def items(self, create, _extracted, **_kwargs): diff --git a/src/purchase/tests/test_cashier_flow.py b/src/purchase/tests/test_cashier_flow.py index b67295d..b1658d5 100644 --- a/src/purchase/tests/test_cashier_flow.py +++ b/src/purchase/tests/test_cashier_flow.py @@ -16,7 +16,6 @@ from purchase.tests.factories import ( BasketWithItemsFactory, CashierFactory, PaymentMethodFactory, - ProductCategoryFactory, ProductFactory, ) @@ -31,8 +30,6 @@ def test_cashier_create_and_update_basket( # noqa: PLR0915 # Setup data cashier = CashierFactory() - ProductCategoryFactory() - ProductCategoryFactory() products = [ ProductFactory(), ProductFactory(), @@ -260,8 +257,6 @@ def test_baskets_list(live_server: LiveServer, selenium: WebDriver): # Setup test data cashier = CashierFactory() - ProductCategoryFactory() - ProductCategoryFactory() _ = [ ProductFactory(), ProductFactory(),