diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-10 15:42:03 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-10 15:42:03 +0100 |
commit | b77af5bb3ecd3aef29223d5c3645295144e790fd (patch) | |
tree | e3707dd828717407c68b12281158c728bccbf385 /ctrack/register | |
parent | 58f026c7e23d4fab7d4fd8f52dd93564deb044c7 (diff) |
playing with mixins
Diffstat (limited to 'ctrack/register')
-rw-r--r-- | ctrack/register/tests/test_engagement_events.py | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/ctrack/register/tests/test_engagement_events.py b/ctrack/register/tests/test_engagement_events.py index 426603c..5e9db31 100644 --- a/ctrack/register/tests/test_engagement_events.py +++ b/ctrack/register/tests/test_engagement_events.py @@ -12,8 +12,11 @@ def event_type(): return EngagementTypeFactory.create(descriptor="CAF type") +type = models.ForeignKey(EngagementType, on_delete=models.CASCADE) + + class EngagementEventBase(models.Model): - type = models.ForeignKey(EngagementType, on_delete=models.CASCADE) + type_descriptor = "Base Type" short_description = models.CharField( max_length=50, help_text="Short description of the event. Use Comments field for full detail.", @@ -26,6 +29,8 @@ class EngagementEventBase(models.Model): help_text="URL only - do not try to drag a file here.", ) response_date_requested = models.DateField(blank=True, null=True) + comments = models.TextField(max_length=1000, blank=True, null=True, + help_text="Use this to provide further detail about the event.") class Meta: abstract = True @@ -50,3 +55,37 @@ def test_event_inheritance(): 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 + + +class MeetingEventMixin(models.Model): + participants = models.ManyToManyField(Person, blank=True) + location = models.CharField(max_length=100, blank=True, null=True) + + class Meta: + abstract = True + + +class SingleDateTimeEventMixin(models.Model): + datetime = models.DateTimeField() + + class Meta: + abstract = True + + +class MeetingEvent(EngagementEventBase, MeetingEventMixin, SingleDateTimeEventMixin): + MEETING_CHOICES = [ + ("Meeting", "Meeting") + ] + type_descriptor = models.CharField(max_length=50, choices=MEETING_CHOICES) + + +def test_meeting_event(org_with_people, person): + e = MeetingEvent.objects.create( + type_descriptor="Meeting", + short_description="Big Important Meeting", + datetime="2020-10-10T15:00", + comments="Nice comments", + location="Harvey's House" + ) + assert len(e.participants.all()) == 0 + assert e.type_descriptor == "Meeting" |