aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-10-11 17:24:54 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-10-11 17:24:54 +0100
commit65b22a3bd3f392422fb2ec9fffc51b70d20cc5aa (patch)
treee996501f6fc647a54a67f9117a8145776ce18f80 /ctrack
parent61e4e92cf683520eb53b4c1d1889f3256a8b754b (diff)
fleshed out more testing
Diffstat (limited to 'ctrack')
-rw-r--r--ctrack/register/forms.py4
-rw-r--r--ctrack/register/models.py6
-rw-r--r--ctrack/register/tests/test_event_models.py65
-rw-r--r--ctrack/register/tests/test_forms.py20
4 files changed, 42 insertions, 53 deletions
diff --git a/ctrack/register/forms.py b/ctrack/register/forms.py
index cff2fe4..b09804e 100644
--- a/ctrack/register/forms.py
+++ b/ctrack/register/forms.py
@@ -9,14 +9,14 @@ from ctrack.organisations.models import Person, Organisation
from ctrack.register.models import (
EngagementEvent,
EngagementType,
- MeetingEvent,
CAFSingleDateEvent,
+ SingleDateTimeEvent,
)
class AddMeetingForm(forms.ModelForm):
class Meta:
- model = MeetingEvent
+ model = SingleDateTimeEvent
fields = [
"type_descriptor",
"short_description",
diff --git a/ctrack/register/models.py b/ctrack/register/models.py
index 673d9e0..d421efb 100644
--- a/ctrack/register/models.py
+++ b/ctrack/register/models.py
@@ -112,6 +112,7 @@ class CAFMixin(models.Model):
class SingleDateTimeEvent(EventBase, ThirdPartyEventMixin, SingleDateTimeEventMixin):
AVAILABLE_TYPES = [
+ (EventType.MEETING.name, "Meeting"),
(EventType.PHONE_CALL.name, "Phone Call"),
(EventType.VIDEO_CALL.name, "Video Call"),
]
@@ -121,11 +122,6 @@ class SingleDateTimeEvent(EventBase, ThirdPartyEventMixin, SingleDateTimeEventMi
return self.type_descriptor
-class MeetingEvent(EventBase, ThirdPartyEventMixin, SingleDateTimeEventMixin):
- AVAILABLE_TYPES = [(EventType.MEETING.name, "Meeting")]
- type_descriptor = models.CharField(max_length=50, choices=AVAILABLE_TYPES)
-
-
class CAFSingleDateEvent(EventBase, CAFMixin, SingleDateMixin):
AVAILABLE_TYPES = [
(EventType.CAF_INITIAL_CAF_RECEIVED.name, "CAF - Initial CAF Received"),
diff --git a/ctrack/register/tests/test_event_models.py b/ctrack/register/tests/test_event_models.py
index 225aa4d..b4e133e 100644
--- a/ctrack/register/tests/test_event_models.py
+++ b/ctrack/register/tests/test_event_models.py
@@ -4,7 +4,6 @@ import pytest
from django.db import IntegrityError
from ctrack.register.models import (
- MeetingEvent,
EventType,
SingleDateTimeEvent,
CAFSingleDateEvent,
@@ -115,10 +114,28 @@ def test_event_type_enum():
)
-def test_meeting_event(person, user):
+@pytest.mark.parametrize("allowed_type", [("PHONE_CALL"), ("MEETING"), ("VIDEO_CALL")])
+def test_single_datetime_event(person, user, allowed_type):
+ """This tests for phone call, video call and email events"""
+ now = datetime.datetime.now()
+ event = SingleDateTimeEvent.objects.create(
+ type_descriptor=allowed_type,
+ short_description="Important event",
+ datetime="2020-10-10T15:00",
+ comments="Comments on important event",
+ # location is optional
+ user=user,
+ )
+ event.participants.add(person)
+ assert event.type_descriptor == allowed_type
+ assert person in event.participants.all()
+ assert event.created_date.day == now.day
+
+
+def test_meeting_event(user, person):
uname = user.name
now = datetime.datetime.now()
- e = MeetingEvent.objects.create(
+ e = SingleDateTimeEvent.objects.create(
type_descriptor="Meeting",
short_description="Big Important Meeting",
datetime="2020-10-10T15:00",
@@ -133,45 +150,3 @@ def test_meeting_event(person, user):
assert e.user.name == uname
assert e.created_date.day == now.day
assert e.modified_date.day == now.day
-
-
-def test_single_date_event(person, user):
- """This tests for phone call, video call and email events"""
- now = datetime.datetime.now()
- phone_event = SingleDateTimeEvent.objects.create(
- type_descriptor="Phone Call",
- short_description="Important Phone Call",
- datetime="2020-10-10T15:00",
- comments="Comments on phone call",
- # location is optional
- user=user,
- )
- phone_event.participants.add(person)
- assert phone_event.type_descriptor == "Phone Call"
- assert person in phone_event.participants.all()
- assert phone_event.created_date.day == now.day
-
- email = SingleDateTimeEvent.objects.create(
- type_descriptor="Video Call",
- short_description="Important Video Call",
- datetime="2020-10-10T15:00",
- comments="Comments on video call",
- # location is optional
- user=user,
- )
- email.participants.add(person)
- assert email.type_descriptor == "Video Call"
- assert person in email.participants.all()
- assert email.created_date.day == now.day
- email = SingleDateTimeEvent.objects.create(
- type_descriptor="Email",
- short_description="Important Email",
- datetime="2020-10-10T15:00",
- comments="Comments on email",
- # location is optional
- user=user,
- )
- email.participants.add(person)
- assert email.type_descriptor == "Email"
- assert person in email.participants.all()
- assert email.created_date.day == now.day
diff --git a/ctrack/register/tests/test_forms.py b/ctrack/register/tests/test_forms.py
index 322ea1c..572b8f8 100644
--- a/ctrack/register/tests/test_forms.py
+++ b/ctrack/register/tests/test_forms.py
@@ -27,6 +27,24 @@ def test_init(user):
assert form.is_valid()
+def test_cannot_create_disallowed_single_date_event_type_with_form(user):
+ form = AddMeetingForm(
+ {
+ "type_descriptor": "NOT ALLOWED EVENT",
+ "short_description": "Test short description",
+ "datetime": "2020-10-10",
+ "comments": "Test Comments",
+ },
+ user=user,
+ )
+ assert form.is_valid() is False
+ assert form.errors == {
+ "type_descriptor": [
+ "Select a valid choice. NOT ALLOWED EVENT is not one of the available choices."
+ ]
+ }
+
+
def test_meeting_blank_data(user):
"""Missing datetime fields is required. Location is optional"""
form = AddMeetingForm(
@@ -49,7 +67,7 @@ def test_meeting_blank_data(user):
("CAF_EMAILED_ROSA"),
],
)
-def test_caf_initial_received_form(allowed_type, user, caf):
+def test_allowable_caf_single_date_event_forms(allowed_type, user, caf):
form = CAFSingleDateEventForm(
{
"type_descriptor": allowed_type,