diff --git a/smash/web/tests/api_views/test_subject.py b/smash/web/tests/api_views/test_subject.py index 0cfe69f569c84e2753c43e7bbb485fbf5d5c0f8c..b3da6195882493d7c95980d006977720ebf2bb12 100644 --- a/smash/web/tests/api_views/test_subject.py +++ b/smash/web/tests/api_views/test_subject.py @@ -10,7 +10,7 @@ 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.constants import GLOBAL_STUDY_ID, SUBJECT_TYPE_CHOICES_PATIENT, SUBJECT_TYPE_CHOICES_CONTROL 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, \ @@ -355,11 +355,44 @@ class TestApi(TestCase): self.check_subject_filtered([["default_location", str(subject.default_location.id)]], [subject]) self.check_subject_filtered([["default_location", "-1"]], []) + def test_subjects_filter_flying_team(self): + subject = self.study_subject + subject.flying_team = create_flying_team() + subject.save() + + self.check_subject_filtered([["flying_team", str(subject.flying_team.id)]], [subject]) + self.check_subject_filtered([["flying_team", "-1"]], []) + + def test_subjects_filter_information_sent(self): + subject = self.study_subject + subject.information_sent = True + subject.save() + + self.check_subject_filtered([["information_sent", "true"]], [subject]) + self.check_subject_filtered([["information_sent", "false"]], []) + + def test_subjects_filter_referral(self): + subject = self.study_subject + subject.referral = "xyz" + subject.save() + + self.check_subject_filtered([["referral", "xyz"]], [subject]) + self.check_subject_filtered([["referral", "false"]], []) + + def test_subjects_filter_type(self): + subject = self.study_subject + subject.type = SUBJECT_TYPE_CHOICES_PATIENT + subject.save() + + self.check_subject_filtered([["type", SUBJECT_TYPE_CHOICES_PATIENT]], [subject]) + self.check_subject_filtered([["type", SUBJECT_TYPE_CHOICES_CONTROL]], []) + def test_subjects_filter_unknown(self): subject = self.study_subject self.check_subject_filtered([["some_unknown", "unknown data"]], [subject]) self.check_subject_filtered([["", ""]], [subject]) + self.check_subject_filtered([["", None]], [subject]) def test_serialize_subject(self): study_subject = self.study_subject