diff options
-rw-r--r-- | ctrack/caf/migrations/0012_auto_20200226_2202.py | 17 | ||||
-rw-r--r-- | ctrack/caf/models.py | 4 | ||||
-rw-r--r-- | ctrack/caf/tests/factories.py | 28 | ||||
-rw-r--r-- | ctrack/organisations/management/commands/populate_db.py | 5 |
4 files changed, 43 insertions, 11 deletions
diff --git a/ctrack/caf/migrations/0012_auto_20200226_2202.py b/ctrack/caf/migrations/0012_auto_20200226_2202.py new file mode 100644 index 0000000..0dbfd17 --- /dev/null +++ b/ctrack/caf/migrations/0012_auto_20200226_2202.py @@ -0,0 +1,17 @@ +# Generated by Django 2.2.9 on 2020-02-26 22:02 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('caf', '0011_auto_20200225_0830'), + ] + + operations = [ + migrations.AlterModelOptions( + name='caffilestore', + options={}, + ), + ] diff --git a/ctrack/caf/models.py b/ctrack/caf/models.py index 820181e..2a9310c 100644 --- a/ctrack/caf/models.py +++ b/ctrack/caf/models.py @@ -25,8 +25,8 @@ class CAFFileStore(models.Model): Organisation, on_delete=models.CASCADE ) - class Meta: - verbose_name = "CAF File Store" + def __str__(self): + return self.descriptor class DocumentFile(models.Model): diff --git a/ctrack/caf/tests/factories.py b/ctrack/caf/tests/factories.py index bae0d9c..ce337f2 100644 --- a/ctrack/caf/tests/factories.py +++ b/ctrack/caf/tests/factories.py @@ -1,9 +1,10 @@ -import factory +import random +import factory from factory import Faker -from ctrack.caf.models import CAF, EssentialService, Grading -from ctrack.organisations.tests.factories import PersonFactory +from ctrack.caf.models import EssentialService, Grading, DocumentFile, FileStore, CAFFileStore +from ctrack.organisations.tests.factories import OrganisationFactory class EssentialServiceFactory(factory.DjangoModelFactory): @@ -22,10 +23,21 @@ class GradingFactory(factory.DjangoModelFactory): model = Grading -class CAFFactory(factory.DjangoModelFactory): - """Factory for CAFs.""" - owner = factory.SubFactory(PersonFactory) -# triage_ranking = factory.SubFactory(TriageRankingFactory) +# TODO: test these two factories +class CAFFileStoreFactory(factory.DjangoModelFactory): + descriptor = "File Store X" + virtual_location = Faker("street_name") + physical_location = random.choice(["Cupboard A", "Tin Box", "The Vault"]) + physical_location_organisation = factory.SubFactory(OrganisationFactory) + + class Meta: + model = CAFFileStore + + +class DocumentFileFactory(factory.DjangoModelFactory): + name = Faker("file_name", extension="xlsx") + type = random.choice([1, 2, 3, 4]) + file_store_location = factory.SubFactory(CAFFileStoreFactory) class Meta: - model = CAF + model = DocumentFile diff --git a/ctrack/organisations/management/commands/populate_db.py b/ctrack/organisations/management/commands/populate_db.py index 3335a11..bcecc1a 100644 --- a/ctrack/organisations/management/commands/populate_db.py +++ b/ctrack/organisations/management/commands/populate_db.py @@ -3,7 +3,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 +from ctrack.caf.tests.factories import GradingFactory, CAFFileStoreFactory from ctrack.organisations.models import AddressType from ctrack.organisations.models import Mode from ctrack.organisations.models import Submode @@ -112,3 +112,6 @@ class Command(BaseCommand): # Confidence gradings for g in ["C1", "C2", "C3", "C4", "C5"]: GradingFactory.create(descriptor=g, type="CONFIDENCE") + + # File store + fs = CAFFileStoreFactory.create(physical_location_organistion=orgs[1]) |