Skip to content
Snippets Groups Projects
Commit 9c37f56e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

unit test for flying team location in api call

parent a8c298ca
No related branches found
No related tags found
1 merge request!100Test coverage unit tests
...@@ -9,7 +9,7 @@ from django.urls import reverse ...@@ -9,7 +9,7 @@ from django.urls import reverse
from web.models import AppointmentTypeLink from web.models import AppointmentTypeLink
from web.tests.functions import create_study_subject, create_worker, create_visit, create_appointment, \ 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.appointment import APPOINTMENT_LIST_GENERIC, APPOINTMENT_LIST_APPROACHING, APPOINTMENT_LIST_UNFINISHED
from web.views.notifications import get_today_midnight_date from web.views.notifications import get_today_midnight_date
...@@ -30,11 +30,14 @@ class TestAppointmentApi(TestCase): ...@@ -30,11 +30,14 @@ class TestAppointmentApi(TestCase):
self.assertEqual(response.status_code, 500) self.assertEqual(response.status_code, 500)
def test_appointments_valid(self): def test_appointments_valid(self):
place = "Some new flying team location"
name = "Piotrek" name = "Piotrek"
self.study_subject.subject.first_name = name self.study_subject.subject.first_name = name
self.study_subject.subject.save() self.study_subject.subject.save()
visit = create_visit(self.study_subject) 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 = create_appointment(visit, get_today_midnight_date())
appointment2.visit = None appointment2.visit = None
...@@ -47,6 +50,20 @@ class TestAppointmentApi(TestCase): ...@@ -47,6 +50,20 @@ class TestAppointmentApi(TestCase):
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertTrue(name in response.content) 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): def test_appointments_approaching(self):
name = "Piotrek" name = "Piotrek"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment