From 39ac1d9cad3e9fcf7e3a85cbea11bc62136e9f7f Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Sun, 3 Dec 2017 10:05:24 +0100 Subject: [PATCH] unit test checking if results are vali when no info about visible columns is available --- smash/web/tests/api_views/test_subject.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/smash/web/tests/api_views/test_subject.py b/smash/web/tests/api_views/test_subject.py index a718164f..7dc320a1 100644 --- a/smash/web/tests/api_views/test_subject.py +++ b/smash/web/tests/api_views/test_subject.py @@ -11,7 +11,8 @@ from django.urls import reverse from web.api_views.subject import get_subjects_order, get_subjects_filtered, serialize_subject from web.models import StudySubject, Appointment, Study from web.models.constants import GLOBAL_STUDY_ID -from web.models.study_subject_list import SUBJECT_LIST_GENERIC, SUBJECT_LIST_NO_VISIT, SUBJECT_LIST_REQUIRE_CONTACT +from web.models.study_subject_list import SUBJECT_LIST_GENERIC, SUBJECT_LIST_NO_VISIT, SUBJECT_LIST_REQUIRE_CONTACT, \ + StudySubjectList from web.tests.functions import create_study_subject, create_worker, create_get_suffix, create_visit, \ create_appointment, create_empty_study_columns from web.views.notifications import get_today_midnight_date @@ -56,6 +57,15 @@ class TestApi(TestCase): columns = json.loads(response.content)['columns'] self.assertTrue(len(columns) >= 20) + def test_get_columns_when_no_list_is_available(self): + StudySubjectList.objects.all().delete() + response = self.client.get( + reverse('web.api.subjects.columns', kwargs={'subject_list_type': SUBJECT_LIST_GENERIC})) + self.assertEqual(response.status_code, 200) + + columns = json.loads(response.content)['columns'] + self.assertTrue(len(columns) > 0) + def test_get_columns_when_study_has_no_data_columns(self): study = Study.objects.filter(id=GLOBAL_STUDY_ID)[0] study.columns = create_empty_study_columns() -- GitLab