diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-11 15:06:40 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-11 15:06:40 +0100 |
commit | d4f1bdfadb39ed966c2aeddba1b7fff898042fe6 (patch) | |
tree | aaec057f1ea0cfb1a4714321eb529d99a203e649 /ctrack | |
parent | 1f47b102acd45129bf8e96713af5dc6265ba2873 (diff) |
done models and form for meeting -with tests
Diffstat (limited to 'ctrack')
-rw-r--r-- | ctrack/register/tests/test_engagement_events.py | 33 | ||||
-rw-r--r-- | ctrack/register/tests/test_event_models.py (renamed from ctrack/register/tests/test_events.py) | 24 | ||||
-rw-r--r-- | ctrack/register/tests/test_forms.py | 9 |
3 files changed, 22 insertions, 44 deletions
diff --git a/ctrack/register/tests/test_engagement_events.py b/ctrack/register/tests/test_engagement_events.py deleted file mode 100644 index 602d027..0000000 --- a/ctrack/register/tests/test_engagement_events.py +++ /dev/null @@ -1,33 +0,0 @@ -"""LEGACY - SPIKE CODE _ TO BE DELETED""" - -# TODO - delete this code - -import datetime - -import pytest - -from ctrack.register.models import MeetingEvent - -pytestmark = pytest.mark.django_db - - -def test_meeting_event(person, user): - uname = user.name - now = datetime.datetime.now() - e = MeetingEvent.objects.create( - type_descriptor="Meeting", - short_description="Big Important Meeting", - datetime="2020-10-10T15:00", - comments="Nice comments", - location="Harvey's House", - user=user - ) - e.participants.add(person) - assert len(e.participants.all()) == 1 - assert e.type_descriptor == "Meeting" - assert person in e.participants.all() - assert e.user.name == uname - assert e.created_date.day == now.day - assert e.created_date.hour == now.hour - assert e.modified_date.day == now.day - assert e.modified_date.hour == now.hour diff --git a/ctrack/register/tests/test_events.py b/ctrack/register/tests/test_event_models.py index b8e4d8b..1871eb8 100644 --- a/ctrack/register/tests/test_events.py +++ b/ctrack/register/tests/test_event_models.py @@ -58,15 +58,27 @@ def test_single_date_event(person, user): assert person in phone_event.participants.all() assert phone_event.created_date.day == now.day - video_event = SingleDateTimeEvent.objects.create( + email = SingleDateTimeEvent.objects.create( type_descriptor="Video Call", short_description="Important Video Call", datetime="2020-10-10T15:00", - comments="Comments on phone call", + 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 ) - video_event.participants.add(person) - assert video_event.type_descriptor == "Video Call" - assert person in video_event.participants.all() - assert video_event.created_date.day == now.day + 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 9a0f541..6d7d914 100644 --- a/ctrack/register/tests/test_forms.py +++ b/ctrack/register/tests/test_forms.py @@ -13,7 +13,7 @@ def test_init(user): We don't want that to be field in the form. """ form = AddMeetingForm({ - "type_descriptor": "Meeting", # Must be Meeting as that is in the choices param + "type_descriptor": "MEETING", # Must be Meeting as that is in the choices param "short_description": "Test short description", "datetime": "2010-10-10T13:00", "comments": "Test Comments", @@ -24,10 +24,10 @@ def test_init(user): assert form.is_valid() -def test_blank_data(user): - """Missing location and datetime fields which are required.""" +def test_meeting_blank_data(user): + """Missing datetime fields is required. Location is optional""" form = AddMeetingForm({ - "type_descriptor": "Meeting", + "type_descriptor": "MEETING", "short_description": "Test short description", "comments": "Test Comments", }, @@ -35,6 +35,5 @@ def test_blank_data(user): ) assert form.is_valid() is False assert form.errors == { - "location": ["This field is required."], "datetime": ["This field is required."] } |