From 9c37f56e76f5b70c44f3178b5bccf9c97d141fd5 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Wed, 29 Nov 2017 11:45:41 +0100 Subject: [PATCH] unit test for flying team location in api call --- smash/web/tests/api_views/test_appointment.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/smash/web/tests/api_views/test_appointment.py b/smash/web/tests/api_views/test_appointment.py index 8e73b875..5074b3dd 100644 --- a/smash/web/tests/api_views/test_appointment.py +++ b/smash/web/tests/api_views/test_appointment.py @@ -9,7 +9,7 @@ from django.urls import reverse from web.models import AppointmentTypeLink from web.tests.functions import create_study_subject, create_worker, create_visit, create_appointment, \ - create_appointment_type, create_get_suffix + create_appointment_type, create_get_suffix, create_flying_team from web.views.appointment import APPOINTMENT_LIST_GENERIC, APPOINTMENT_LIST_APPROACHING, APPOINTMENT_LIST_UNFINISHED from web.views.notifications import get_today_midnight_date @@ -30,11 +30,14 @@ class TestAppointmentApi(TestCase): self.assertEqual(response.status_code, 500) def test_appointments_valid(self): + place = "Some new flying team location" name = "Piotrek" self.study_subject.subject.first_name = name self.study_subject.subject.save() visit = create_visit(self.study_subject) - create_appointment(visit) + appointment = create_appointment(visit) + appointment.flying_team = create_flying_team(place=place) + appointment.save() appointment2 = create_appointment(visit, get_today_midnight_date()) appointment2.visit = None @@ -47,6 +50,20 @@ class TestAppointmentApi(TestCase): self.assertEqual(response.status_code, 200) self.assertTrue(name in response.content) + self.assertTrue(place in response.content) + + def test_flying_team_location_in_appointments(self): + place = "Some new flying team location" + visit = create_visit(self.study_subject) + appointment = create_appointment(visit) + appointment.flying_team = create_flying_team(place=place) + appointment.save() + + url = reverse('web.api.appointments', kwargs={'type': APPOINTMENT_LIST_GENERIC}) + response = self.client.get(url) + + self.assertEqual(response.status_code, 200) + self.assertTrue(place in response.content) def test_appointments_approaching(self): name = "Piotrek" -- GitLab