From 5d27164f5d079aa710f4c3a0ed1506ee92e45732 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Thu, 28 Apr 2022 19:28:53 +0200 Subject: [PATCH] Sometimes generate dummy baskets without payment method --- src/purchase/management/commands/generate_dummy_baskets.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/purchase/management/commands/generate_dummy_baskets.py b/src/purchase/management/commands/generate_dummy_baskets.py index 6e00ebc..d84c220 100644 --- a/src/purchase/management/commands/generate_dummy_baskets.py +++ b/src/purchase/management/commands/generate_dummy_baskets.py @@ -35,9 +35,9 @@ class Command(BaseCommand): methods_weights = [random.randint(1, 6) for _ in range(len(payment_methods))] products_weights = [1 / product.display_order for product in products] for _ in range(count): - method: PaymentMethod = random.choices( - payment_methods, weights=methods_weights - )[0] + method = None + if random.random() < 0.99: + method = random.choices(payment_methods, weights=methods_weights)[0] basket = Basket.objects.create(payment_method=method) items = [] item_count = int(random.normalvariate(3, 2))