diff options
Diffstat (limited to '')
-rw-r--r-- | ctrack/register/tests.py | 3 | ||||
-rw-r--r-- | ctrack/register/tests/__init__.py | 0 | ||||
-rw-r--r-- | ctrack/register/tests/factories.py | 69 |
3 files changed, 69 insertions, 3 deletions
diff --git a/ctrack/register/tests.py b/ctrack/register/tests.py deleted file mode 100644 index 4d66077..0000000 --- a/ctrack/register/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -#from django.test import TestCase - -# Create your tests here. diff --git a/ctrack/register/tests/__init__.py b/ctrack/register/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ctrack/register/tests/__init__.py diff --git a/ctrack/register/tests/factories.py b/ctrack/register/tests/factories.py new file mode 100644 index 0000000..963c1a5 --- /dev/null +++ b/ctrack/register/tests/factories.py @@ -0,0 +1,69 @@ +import factory +import string +import random + +from django.utils import timezone + +from django.contrib.auth import get_user_model +from factory import post_generation + +from ctrack.register.models import EngagementEvent +from ctrack.register.models import EngagementType + +User = get_user_model() + + +def _regulation_scrambler(): + reg_type = ["Act", "Regulations", "Directive"] + reg_titles = [ + "NIS", + "ISO", + "NIRST", + "BIRST", + "Civil Communications", + "Paralegal Consequences", + "Marine and Inner-Waters", + "Rail Bridges and Overhead Wires", + "Internal Platform Sewage", + "Electrical Wires", + "Cyber Consciousness", + ] + section = ["Paragraph", "Section", "Appendix", "Chapter"] + return ( + f"{random.choice(reg_titles)} {random.choice(reg_type)} " + f"{str(random.randint(1945, 2020))} - " + f"{random.choice(section)} {str(random.randint(1, 100))}({random.choice(string.ascii_lowercase[:3])})" + ) + + +class EngagementTypeFactory(factory.DjangoModelFactory): + class Meta: + model = EngagementType + + descriptor = "Generic Engagement Type" + enforcement_instrument = True + regulation_reference = factory.LazyFunction(_regulation_scrambler) + + +class EngagementEventFactory(factory.DjangoModelFactory): + class Meta: + model = EngagementEvent + + @post_generation + def participants(self, create, extracted, **kwargs): + if not create: + return + if extracted: + for p in extracted: + self.participants.add(p) + + type = factory.SubFactory(EngagementTypeFactory) + short_description = factory.LazyAttribute(lambda o: f"An event related to {o.type.descriptor}") + # particpants fed in + # user fed in + date = factory.LazyFunction(timezone.now) + end_date = factory.LazyFunction(timezone.now) + document_link = factory.Faker("uri") + response_date_requested = factory.LazyFunction(timezone.now) + response_received = None + related_caf = None |