diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-02-26 22:04:26 +0000 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-02-26 22:04:26 +0000 |
commit | 77572ddf5122947d98a26082d774d6d2c0a74d16 (patch) | |
tree | 45c0b8ecc37dcc8da96da7ac69371af5a2e8d16a /ctrack/caf | |
parent | 70a8f6e37a462f2508ed024b2ee34f0df6b16a3b (diff) |
tweaks - added factories for CAFFileStore and DocumentFile
Diffstat (limited to '')
-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 |
3 files changed, 39 insertions, 10 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 |