diff --git a/smash/web/tests/api_views/test_subject.py b/smash/web/tests/api_views/test_subject.py index a718164f15694d00684e91c6baa9e4a25db28182..7dc320a195db39709542773cd26735e09dfc0cdd 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()