aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-10-09 16:16:09 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-10-09 16:16:09 +0100
commit58f026c7e23d4fab7d4fd8f52dd93564deb044c7 (patch)
tree8c7752c375260254bb5e48f3cde4da7f886ce84a
parentd1ca34da126798c379283d4386d7cf436589eb09 (diff)
tests up
-rw-r--r--config/settings/test.py2
-rw-r--r--ctrack/register/tests/test_engagement_events.py52
2 files changed, 53 insertions, 1 deletions
diff --git a/config/settings/test.py b/config/settings/test.py
index 718cbdb..0f994fc 100644
--- a/config/settings/test.py
+++ b/config/settings/test.py
@@ -2,7 +2,7 @@
With these settings, tests run faster.
"""
-from .base import * # noqa
+from .gcloud_settings import * # noqa
from .base import env
# GENERAL
diff --git a/ctrack/register/tests/test_engagement_events.py b/ctrack/register/tests/test_engagement_events.py
new file mode 100644
index 0000000..426603c
--- /dev/null
+++ b/ctrack/register/tests/test_engagement_events.py
@@ -0,0 +1,52 @@
+import pytest
+from django.db import models
+
+from ctrack.organisations.models import Person
+from ctrack.register.models import EngagementType
+from ctrack.register.tests.factories import EngagementTypeFactory
+
+pytestmark = pytest.mark.django_db
+
+
+def event_type():
+ return EngagementTypeFactory.create(descriptor="CAF type")
+
+
+class EngagementEventBase(models.Model):
+ type = models.ForeignKey(EngagementType, on_delete=models.CASCADE)
+ short_description = models.CharField(
+ max_length=50,
+ help_text="Short description of the event. Use Comments field for full detail.",
+ )
+ participants = models.ManyToManyField(Person, null=True, blank=True)
+ document_link = models.URLField(
+ max_length=1000,
+ blank=True,
+ null=True,
+ help_text="URL only - do not try to drag a file here.",
+ )
+ response_date_requested = models.DateField(blank=True, null=True)
+
+ class Meta:
+ abstract = True
+
+
+class SingleDateCAFEvent(EngagementEventBase):
+ type = models.ForeignKey(
+ EngagementType, default=event_type, on_delete=models.CASCADE
+ )
+ caf_related = models.BooleanField(default=True)
+ date = models.DateField(blank=False, null=False)
+
+
+def test_event_inheritance():
+ caf_single_date_event = SingleDateCAFEvent.objects.create(
+ short_description="Test Short Description", date="2010-10-10"
+ )
+ assert isinstance(caf_single_date_event.type, EngagementType)
+ assert caf_single_date_event.short_description == "Test Short Description"
+ assert caf_single_date_event.caf_related is True
+ assert len(caf_single_date_event.participants.all()) == 0
+ assert caf_single_date_event.date == "2010-10-10"
+ assert caf_single_date_event.document_link is None
+ assert caf_single_date_event.response_date_requested is None