diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-11 17:01:45 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-11 17:01:45 +0100 |
commit | 61e4e92cf683520eb53b4c1d1889f3256a8b754b (patch) | |
tree | 86a5eb3da74d569326e8f188b2ae497b6bccaab7 /ctrack/register/tests | |
parent | ca6a7cc617f9f0fb37931a1268a75ab9ec1879cd (diff) |
more testing of CAFSingleDateEventForm
Diffstat (limited to '')
-rw-r--r-- | ctrack/register/tests/test_forms.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/ctrack/register/tests/test_forms.py b/ctrack/register/tests/test_forms.py index f13662d..322ea1c 100644 --- a/ctrack/register/tests/test_forms.py +++ b/ctrack/register/tests/test_forms.py @@ -1,4 +1,5 @@ import pytest +from django.db import IntegrityError from ..forms import AddMeetingForm, CAFSingleDateEventForm @@ -60,3 +61,56 @@ def test_caf_initial_received_form(allowed_type, user, caf): user=user, ) assert form.is_valid() + + +def test_cannot_create_two_caf_initial_receipt_events_on_same_day(user, caf): + form1 = CAFSingleDateEventForm( + { + "type_descriptor": "CAF_INITIAL_CAF_RECEIVED", + "related_caf": caf, + "short_description": "Test Short Description", + "date": "2010-07-01", + "comments": "Meaningless comments", + }, + user=user, + ) + form2 = CAFSingleDateEventForm( + { + "type_descriptor": "CAF_INITIAL_CAF_RECEIVED", + "related_caf": caf, + "short_description": "Test Short Description", + "date": "2010-07-01", + "comments": "Meaningless comments", + }, + user=user, + ) + assert form1.is_valid() + form1.save() + assert form2.is_valid() + with pytest.raises(IntegrityError): + form2.save() + + +def test_can_register_two_send_to_rosa_events_on_same_day(user, caf): + form1 = CAFSingleDateEventForm( + { + "type_descriptor": "CAF_EMAILED_ROSA", + "related_caf": caf, + "short_description": "Test Short Description", + "date": "2010-07-01", + "comments": "Meaningless comments", + }, + user=user, + ) + form2 = CAFSingleDateEventForm( + { + "type_descriptor": "CAF_EMAILED_ROSA", + "related_caf": caf, + "short_description": "Test Short Description 2", + "date": "2010-07-01", + "comments": "Meaningless comments 2", + }, + user=user, + ) + assert form1.is_valid() + assert form2.is_valid() |