diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-14 17:01:22 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-14 17:01:22 +0100 |
commit | 14fa59eee9ba35ad462b5b17229a09164f5d716d (patch) | |
tree | 1223522b7cc30cf57ad8ec66e50c5081727fe3d4 /ctrack/register/tests | |
parent | bc4edc69407f20da32a48d534b3d725cc3818c1a (diff) |
about to nuke migrations
Diffstat (limited to '')
-rw-r--r-- | ctrack/register/tests/test_event_models.py | 5 | ||||
-rw-r--r-- | ctrack/register/tests/test_forms.py | 37 |
2 files changed, 37 insertions, 5 deletions
diff --git a/ctrack/register/tests/test_event_models.py b/ctrack/register/tests/test_event_models.py index cb6e0db..6469ea7 100644 --- a/ctrack/register/tests/test_event_models.py +++ b/ctrack/register/tests/test_event_models.py @@ -149,6 +149,7 @@ def test_event_type_enum(): assert EventType.MEETING.name == "MEETING" assert EventType.PHONE_CALL.name == "PHONE_CALL" assert EventType.VIDEO_CALL.name == "VIDEO_CALL" + assert EventType.EMAIL.name == "EMAIL" assert EventType.CAF_INITIAL_CAF_RECEIVED.name == "CAF_INITIAL_CAF_RECEIVED" assert EventType.CAF_FEEDBACK_EMAILED_OES.name == "CAF_FEEDBACK_EMAILED_OES" assert EventType.CAF_RECEIVED.name == "CAF_RECEIVED" @@ -162,13 +163,15 @@ def test_event_type_enum(): ) -@pytest.mark.parametrize("allowed_type", ["PHONE_CALL", "MEETING", "VIDEO_CALL"]) +@pytest.mark.parametrize("allowed_type", ["PHONE_CALL", "MEETING", "VIDEO_CALL", "EMAIL"]) 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", + requested_response_date="2021-01-24", + response_received_date=None, datetime="2020-10-10T15:00", comments="Comments on important event", # location is optional diff --git a/ctrack/register/tests/test_forms.py b/ctrack/register/tests/test_forms.py index 49cd5b4..16d81ae 100644 --- a/ctrack/register/tests/test_forms.py +++ b/ctrack/register/tests/test_forms.py @@ -1,7 +1,7 @@ import pytest from django.db import IntegrityError -from ..forms import AddMeetingForm, CAFSingleDateEventForm, CAFTwinDateEventForm +from ..forms import CreateSimpleDateTimeEventForm, CAFSingleDateEventForm, CAFTwinDateEventForm pytestmark = pytest.mark.django_db @@ -14,7 +14,7 @@ def test_init(user): """Here we test that we can pass in the user value from the view. We don't want that to be field in the form. """ - form = AddMeetingForm( + form = CreateSimpleDateTimeEventForm( { "type_descriptor": "MEETING", # Must be Meeting as that is in the choices param "short_description": "Test short description", @@ -28,7 +28,7 @@ def test_init(user): def test_cannot_create_disallowed_single_date_event_type_with_form(user): - form = AddMeetingForm( + form = CreateSimpleDateTimeEventForm( { "type_descriptor": "NOT ALLOWED EVENT", "short_description": "Test short description", @@ -45,9 +45,38 @@ def test_cannot_create_disallowed_single_date_event_type_with_form(user): } +def test_create_simple_datetime_event(user): + form = CreateSimpleDateTimeEventForm( + { + "type_descriptor": "PHONE_CALL", + "short_description": "Test Short Description", + "datetime": "2010-10-10 10:00", + "requested_response_date": "2020-12-24", + "response_received_date": "2020-12-25", + "comments": "Test Comments not needed" + }, user=user, + ) + assert form.is_valid() + + +def test_response_date_cannot_be_before_date(user): + form = CreateSimpleDateTimeEventForm( + { + "type_descriptor": "PHONE_CALL", + "short_description": "Test Short Description", + "datetime": "2010-10-10 10:00", + "requested_response_date": "2009-12-24", + "response_received_date": None, + "comments": "Test Comments not needed" + }, user=user, + ) + assert not form.is_valid() + assert form.errors == {"__all__": ["Requested response cannot be before date."]} + + def test_meeting_blank_data(user): """Missing datetime fields is required. Location is optional""" - form = AddMeetingForm( + form = CreateSimpleDateTimeEventForm( { "type_descriptor": "MEETING", "short_description": "Test short description", |