From 80fd8f1926e05a9c4ebd9ddc6e129a9c90a9e3ba Mon Sep 17 00:00:00 2001 From: Nina Menezes Date: Thu, 4 Apr 2024 19:38:16 +0100 Subject: [PATCH] Update dummy data creation to pass in a flag to generate themes or not. --- .../consultations/dummy_data.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/consultation_analyser/consultations/dummy_data.py b/consultation_analyser/consultations/dummy_data.py index 911aeffb2..48fbb1818 100644 --- a/consultation_analyser/consultations/dummy_data.py +++ b/consultation_analyser/consultations/dummy_data.py @@ -13,7 +13,7 @@ class DummyConsultation: - def __init__(self, responses=10, **options): + def __init__(self, responses=10, include_themes=True, **options): if not HostingEnvironment.is_local(): raise RuntimeError("Dummy data generation should only be run in development") @@ -24,10 +24,11 @@ def __init__(self, responses=10, **options): response = ConsultationResponseFactory(consultation=consultation) _answers = [AnswerFactory(question=q, consultation_response=response) for q in questions] - # Set themes per question, multiple answers with the same theme - for q in questions: - themes = [ThemeFactory() for _ in range(2, 6)] - for a in _answers: - random_theme = random.choice(themes) - a.theme = random_theme - a.save() + if include_themes: + # Set themes per question, multiple answers with the same theme + for q in questions: + themes = [ThemeFactory() for _ in range(2, 6)] + for a in _answers: + random_theme = random.choice(themes) + a.theme = random_theme + a.save()