Fix product categories

This commit is contained in:
Gabriel Augendre 2023-04-02 19:48:13 +02:00
parent 55b6cb9cb8
commit a9599d504d
2 changed files with 2 additions and 7 deletions

View file

@ -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):

View file

@ -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(),