From 41a67d4231c47bb5dc44b541b7d360ac79d21194 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Fri, 28 Feb 2020 22:43:01 +0000 Subject: CAF factory basics but not essential services yet --- ctrack/caf/tests/factories.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'ctrack/caf/tests') diff --git a/ctrack/caf/tests/factories.py b/ctrack/caf/tests/factories.py index 53953fe..4de76a1 100644 --- a/ctrack/caf/tests/factories.py +++ b/ctrack/caf/tests/factories.py @@ -3,19 +3,53 @@ import random import factory from factory import Faker -from ctrack.caf.models import EssentialService, Grading, DocumentFile, FileStore +from ctrack.caf.models import EssentialService, Grading, DocumentFile, FileStore, CAF from ctrack.organisations.tests.factories import OrganisationFactory +class CAFFactory(factory.DjangoModelFactory): + owner = factory.SubFactory(OrganisationFactory) + quality_grading = factory.SubFactory("ctrack.caf.tests.factories.GradingFactory") + confidence_grading = factory.SubFactory("ctrack.caf.tests.factories.GradingFactory") + file = None + + class Meta: + model = CAF + + 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) + 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 GradingFactory(factory.DjangoModelFactory): - descriptor = factory.Iterator(["Q1", "Q2", "Q3", "Q4", "Q5", "C1", "C2", "C3", "C4", "C5"]) + descriptor = factory.Iterator( + ["Q1", "Q2", "Q3", "Q4", "Q5", "C1", "C2", "C3", "C4", "C5"] + ) description = Faker("text", max_nb_chars=100, ext_word_list=None) type = factory.Iterator(Grading.GRADING_TYPE, getter=lambda g: g[0]) -- cgit v1.2.3