Skip to content
Snippets Groups Projects

Resolve "list of subjects should contain columns dependent on the study"

1 file
+ 11
1
Compare changes
  • Side-by-side
  • Inline
@@ -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()
Loading