diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-09 16:16:09 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-09 16:16:09 +0100 |
commit | 58f026c7e23d4fab7d4fd8f52dd93564deb044c7 (patch) | |
tree | 8c7752c375260254bb5e48f3cde4da7f886ce84a /ctrack/register | |
parent | d1ca34da126798c379283d4386d7cf436589eb09 (diff) |
tests up
Diffstat (limited to 'ctrack/register')
-rw-r--r-- | ctrack/register/tests/test_engagement_events.py | 52 |
1 files changed, 52 insertions, 0 deletions
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 |