aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/register/tests
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/register/tests
parent61e4e92cf683520eb53b4c1d1889f3256a8b754b (diff)
fleshed out more testing
Diffstat (limited to '')
-rw-r--r--ctrack/register/tests/test_event_models.py65
-rw-r--r--ctrack/register/tests/test_forms.py20
2 files changed, 39 insertions, 46 deletions
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,