diff --git a/smash/web/tests/api_views/test_appointment.py b/smash/web/tests/api_views/test_appointment.py index 0fafe6c62f2c1584fda7332a30901122dbdf85b0..ddfa8eebc56eb056094726ecfd0b8debcf506675 100644 --- a/smash/web/tests/api_views/test_appointment.py +++ b/smash/web/tests/api_views/test_appointment.py @@ -1,13 +1,14 @@ # coding=utf-8 import datetime +import json from django.contrib.auth.models import User from django.test import Client from django.test import TestCase from django.urls import reverse -from web.models import AppointmentTypeLink +from web.models import AppointmentTypeLink, AppointmentList from web.tests.functions import create_study_subject, create_worker, create_visit, create_appointment, \ create_appointment_type, create_get_suffix, create_flying_team from web.views.appointment import APPOINTMENT_LIST_GENERIC, APPOINTMENT_LIST_APPROACHING, APPOINTMENT_LIST_UNFINISHED @@ -115,3 +116,36 @@ class TestAppointmentApi(TestCase): self.assertEqual(response.status_code, 200) self.assertTrue(name in response.content) + + def test_get_columns(self): + response = self.client.get( + reverse('web.api.appointments.columns', kwargs={'appointment_list_type': APPOINTMENT_LIST_GENERIC})) + self.assertEqual(response.status_code, 200) + + columns = json.loads(response.content)['columns'] + visible_columns = 0 + for column in columns: + if column["visible"]: + visible_columns += 1 + self.assertTrue(visible_columns > 0) + + def test_get_columns_for_require_contact(self): + response = self.client.get( + reverse('web.api.appointments.columns', kwargs={'appointment_list_type': APPOINTMENT_LIST_UNFINISHED})) + self.assertEqual(response.status_code, 200) + + columns = json.loads(response.content)['columns'] + visible_columns = 0 + for column in columns: + if column["visible"]: + visible_columns += 1 + self.assertTrue(visible_columns > 0) + + def test_get_columns_when_no_list_is_available(self): + AppointmentList.objects.all().delete() + response = self.client.get( + reverse('web.api.appointments.columns', kwargs={'appointment_list_type': APPOINTMENT_LIST_GENERIC})) + self.assertEqual(response.status_code, 200) + + columns = json.loads(response.content)['columns'] + self.assertTrue(len(columns) > 0)