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

unit test checking if column list generation is done properly

parent 2461fb76
No related branches found
No related tags found
1 merge request!111Resolve "Unfinished appointments"
# coding=utf-8 # coding=utf-8
import datetime import datetime
import json
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.test import Client from django.test import Client
from django.test import TestCase from django.test import TestCase
from django.urls import reverse 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, \ from web.tests.functions import create_study_subject, create_worker, create_visit, create_appointment, \
create_appointment_type, create_get_suffix, create_flying_team 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
...@@ -115,3 +116,36 @@ class TestAppointmentApi(TestCase): ...@@ -115,3 +116,36 @@ 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)
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)
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