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

unit test checking if results are vali when no info about visible columns is available

parent be701969
No related branches found
No related tags found
1 merge request!101Resolve "list of subjects should contain columns dependent on the study"
...@@ -11,7 +11,8 @@ from django.urls import reverse ...@@ -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.api_views.subject import get_subjects_order, get_subjects_filtered, serialize_subject
from web.models import StudySubject, Appointment, Study from web.models import StudySubject, Appointment, Study
from web.models.constants import GLOBAL_STUDY_ID 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, \ from web.tests.functions import create_study_subject, create_worker, create_get_suffix, create_visit, \
create_appointment, create_empty_study_columns create_appointment, create_empty_study_columns
from web.views.notifications import get_today_midnight_date from web.views.notifications import get_today_midnight_date
...@@ -56,6 +57,15 @@ class TestApi(TestCase): ...@@ -56,6 +57,15 @@ class TestApi(TestCase):
columns = json.loads(response.content)['columns'] columns = json.loads(response.content)['columns']
self.assertTrue(len(columns) >= 20) 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): def test_get_columns_when_study_has_no_data_columns(self):
study = Study.objects.filter(id=GLOBAL_STUDY_ID)[0] study = Study.objects.filter(id=GLOBAL_STUDY_ID)[0]
study.columns = create_empty_study_columns() study.columns = create_empty_study_columns()
......
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