aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctrack/caf/tests/factories.py23
-rw-r--r--ctrack/organisations/management/commands/populate_db.py31
-rw-r--r--utility/truncate_script.sql3
3 files changed, 35 insertions, 22 deletions
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)
+ ]
diff --git a/utility/truncate_script.sql b/utility/truncate_script.sql
index bf0138b..929cd9a 100644
--- a/utility/truncate_script.sql
+++ b/utility/truncate_script.sql
@@ -8,4 +8,7 @@ TRUNCATE TABLE organisations_addresstype RESTART IDENTITY CASCADE;
TRUNCATE TABLE register_engagementevent_participants RESTART IDENTITY CASCADE;
TRUNCATE TABLE register_engagementtype RESTART IDENTITY CASCADE;
TRUNCATE TABLE register_engagementevent RESTART IDENTITY CASCADE;
+TRUNCATE TABLE caf_grading RESTART IDENTITY CASCADE;
+TRUNCATE TABLE caf_caf RESTART IDENTITY CASCADE;
+TRUNCATE TABLE caf_essentialservice RESTART IDENTITY CASCADE;
DELETE FROM users_user WHERE username != 'mrlemon';