diff options
Diffstat (limited to 'ctrack')
-rw-r--r-- | ctrack/register/models.py | 6 | ||||
-rw-r--r-- | ctrack/register/tests/test_event_models.py | 29 |
2 files changed, 28 insertions, 7 deletions
diff --git a/ctrack/register/models.py b/ctrack/register/models.py index 0358b00..673d9e0 100644 --- a/ctrack/register/models.py +++ b/ctrack/register/models.py @@ -16,10 +16,12 @@ class EventType(Enum): MEETING = auto() PHONE_CALL = auto() VIDEO_CALL = auto() + # single date caf events CAF_INITIAL_CAF_RECEIVED = auto() CAF_FEEDBACK_EMAILED_OES = auto() CAF_RECEIVED = auto() CAF_EMAILED_ROSA = auto() + # twin date caf events CAF_PEER_REVIEW_PERIOD = auto() CAF_VALIDATION_PERIOD = auto() CAF_VALIDATION_SIGN_OFF = auto() @@ -126,7 +128,9 @@ class MeetingEvent(EventBase, ThirdPartyEventMixin, SingleDateTimeEventMixin): class CAFSingleDateEvent(EventBase, CAFMixin, SingleDateMixin): AVAILABLE_TYPES = [ - (EventType.CAF_INITIAL_CAF_RECEIVED.name, "CAF - Initial CAF Received") + (EventType.CAF_INITIAL_CAF_RECEIVED.name, "CAF - Initial CAF Received"), + (EventType.CAF_RECEIVED.name, "CAF - Received"), + (EventType.CAF_EMAILED_ROSA.name, "CAF - Emailed to Rosa"), ] type_descriptor = models.CharField(max_length=50, choices=AVAILABLE_TYPES) diff --git a/ctrack/register/tests/test_event_models.py b/ctrack/register/tests/test_event_models.py index 4d72d22..225aa4d 100644 --- a/ctrack/register/tests/test_event_models.py +++ b/ctrack/register/tests/test_event_models.py @@ -60,8 +60,7 @@ def test_caf_initial_caf_emailed_rosa(user, caf): def test_can_email_two_caf_on_same_date(user, caf): - now = datetime.datetime.now() - e1 = CAFSingleDateEvent.objects.create( + CAFSingleDateEvent.objects.create( type_descriptor="CAF_EMAILED_ROSA", related_caf=caf, short_description="CAF sent to Rosa for X Company", @@ -69,16 +68,34 @@ def test_can_email_two_caf_on_same_date(user, caf): comments="Nice comments for this event", user=user, ) - e2 = CAFSingleDateEvent.objects.create( - type_descriptor="CAF_INITIAL_CAF_EMAILED_ROSA", + CAFSingleDateEvent.objects.create( + type_descriptor="CAF_EMAILED_ROSA", related_caf=caf, short_description="CAF sent to Rosa for X Company", date="2020-10-10", comments="Nice comments for this event", user=user, ) - assert e1.created_date.day == now.day - assert e2.created_date.day == now.day + + +def test_cannot_receive_the_same_caf_on_the_same_day(user, caf): + CAFSingleDateEvent.objects.create( + type_descriptor="CAF_RECEIVED", + related_caf=caf, + short_description="CAF received to Rosa for X Company", + date="2020-10-10", + comments="Nice comments for this event", + user=user, + ) + with pytest.raises(IntegrityError): + CAFSingleDateEvent.objects.create( + type_descriptor="CAF_RECEIVED", + related_caf=caf, + short_description="CAF received to Rosa for X Company", + date="2020-10-10", + comments="Nice comments for this event", + user=user, + ) def test_event_type_enum(): |