From d74339006cb6a1e42aef6622fa9b7e5eca861ca2 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Sat, 29 Feb 2020 08:06:34 +0000 Subject: populates with essential services --- ctrack/caf/tests/factories.py | 23 +++------------- .../management/commands/populate_db.py | 31 +++++++++++++++++++--- 2 files changed, 32 insertions(+), 22 deletions(-) (limited to 'ctrack') diff --git a/ctrack/caf/tests/factories.py b/ctrack/caf/tests/factories.py index 4de76a1..1492db4 100644 --- a/ctrack/caf/tests/factories.py +++ b/ctrack/caf/tests/factories.py @@ -20,31 +20,16 @@ class CAFFactory(factory.DjangoModelFactory): class EssentialServiceFactory(factory.DjangoModelFactory): """Factory for Essential Services.""" - fnames = [ - "Clock Pylon Systems", - "Ultramarine Hanglider Navigator", - "Membranous Floor Heaters", - "Alan's Wardrobe Hinge Circuits", - "Marine Sluicegate Extension Pulleys", - "Ironway Prob Modelling Area", - "Bufferage Clippers", - "Slow Gauze Thread Manipulator", - "Terratoast Piling", - "Accounting and Warehouse Conducer", - "Able Hopscotch Mirrors", - "Jolly Main Legacy Circuitry", - ] - - class Meta: - model = EssentialService - - name = random.choice(fnames) + name = Faker("text", max_nb_chars=100, ext_word_list=None) description = Faker( "paragraph", nb_sentences=4, variable_nb_sentences=True, ext_word_list=None ) organisation = factory.SubFactory(OrganisationFactory) caf = factory.SubFactory("ctrack.caf.tests.factories.CAFFactory") + class Meta: + model = EssentialService + class GradingFactory(factory.DjangoModelFactory): descriptor = factory.Iterator( diff --git a/ctrack/organisations/management/commands/populate_db.py b/ctrack/organisations/management/commands/populate_db.py index 32e6ce4..e2bb23b 100644 --- a/ctrack/organisations/management/commands/populate_db.py +++ b/ctrack/organisations/management/commands/populate_db.py @@ -4,7 +4,7 @@ from random import randint, choice from django.core.management import BaseCommand from django.core.management import CommandParser -from ctrack.caf.tests.factories import GradingFactory, FileStoreFactory, CAFFactory +from ctrack.caf.tests.factories import GradingFactory, FileStoreFactory, CAFFactory, EssentialServiceFactory from ctrack.organisations.models import AddressType from ctrack.organisations.models import Mode from ctrack.organisations.models import Submode @@ -16,6 +16,21 @@ from ctrack.organisations.tests.factories import UserFactory from ctrack.register.tests.factories import EngagementEventFactory from ctrack.register.tests.factories import EngagementTypeFactory +fnames = [ + "Clock Pylon Systems", + "Ultramarine Hanglider Navigator", + "Membranous Floor Heaters", + "Alan's Wardrobe Hinge Circuits", + "Marine Sluicegate Extension Pulleys", + "Ironway Prob Modelling Area", + "Bufferage Clippers", + "Slow Gauze Thread Manipulator", + "Terratoast Piling", + "Accounting and Warehouse Conducer", + "Able Hopscotch Mirrors", + "Jolly Main Legacy Circuitry", +] + class Command(BaseCommand): help = """ @@ -120,9 +135,19 @@ class Command(BaseCommand): fs = FileStoreFactory.create(physical_location_organisation=orgs[1]) # Some CAF objects - for c in range(35): + cafs = [ CAFFactory.create( owner=random.choice(orgs), quality_grading__descriptor=random.choice(q_descriptors), confidence_grading__descriptor=random.choice(c_descriptors), - ) + ) for _ in range(35) + ] + + # TODO: Need to create a bunch of Essential Services to associate with these CAFs + es = [ + EssentialServiceFactory.create( + name=random.choice(fnames), + organisation=random.choice(orgs), + caf=random.choice(cafs) + ) for _ in range(35) + ] -- cgit v1.2.3