Skip to content
Snippets Groups Projects

Resolve "exceeded visits list & unfinished visits list"

Merged Piotr Gawron requested to merge 146-exceeded-visits-list-unfinished-visits-list into master
1 file
+ 97
6
Compare changes
  • Side-by-side
  • Inline
@@ -6,12 +6,13 @@ import logging
from django.urls import reverse
from web.api_views.visit import get_visits_filtered, get_visits_order
from web.models import Visit
from web.models import Visit, AppointmentTypeLink, Appointment
from web.models.study_visit_list import VISIT_LIST_GENERIC, VISIT_LIST_EXCEEDED_TIME, VISIT_LIST_UNFINISHED, \
VISIT_LIST_MISSING_APPOINTMENTS, VISIT_LIST_APPROACHING_WITHOUT_APPOINTMENTS, \
VISIT_LIST_APPROACHING_FOR_MAIL_CONTACT
from web.tests import LoggedInWithWorkerTestCase
from web.tests.functions import create_study_subject, create_get_suffix, create_visit
from web.tests.functions import create_study_subject, create_get_suffix, create_visit, create_appointment_type, \
create_flying_team, create_appointment
from web.views.notifications import get_today_midnight_date
logger = logging.getLogger(__name__)
@@ -42,6 +43,12 @@ class TestVisitApi(LoggedInWithWorkerTestCase):
response = self.client.get(reverse('web.api.visits', kwargs={'visit_list_type': VISIT_LIST_EXCEEDED_TIME}))
self.assertEqual(response.status_code, 200)
def test_visits_generic(self):
self.visit.appointment_types.add(create_appointment_type())
self.visit.save()
response = self.client.get(reverse('web.api.visits', kwargs={'visit_list_type': VISIT_LIST_GENERIC}))
self.assertEqual(response.status_code, 200)
def test_visits_unfinished(self):
response = self.client.get(reverse('web.api.visits', kwargs={'visit_list_type': VISIT_LIST_UNFINISHED}))
self.assertEqual(response.status_code, 200)
@@ -176,7 +183,91 @@ class TestVisitApi(LoggedInWithWorkerTestCase):
# visit_number is adjusted automatically according to start date
self.check_visit_ordered("visit_number", [visit1, visit2])
def test_subjects_filter_unknown(self):
self.check_visit_ordered([["some_unknown", "unknown data"]], [self.visit])
self.check_visit_ordered([["", ""]], [self.visit])
self.check_visit_ordered([["", None]], [self.visit])
def test_visits_sort_unknown(self):
self.check_visit_ordered("some_unknown", [self.visit])
self.check_visit_ordered("", [self.visit])
self.check_visit_ordered(None, [self.visit])
def test_visits_filter_last_name(self):
subject = self.study_subject
subject.subject.last_name = "XXX"
subject.subject.save()
self.check_visit_filtered([["last_name", "Q"]], [])
self.check_visit_filtered([["last_name", "xx"]], [self.visit])
def test_visits_filter_flying_team(self):
subject = self.study_subject
subject.flying_team = create_flying_team()
subject.save()
self.check_visit_filtered([["flying_team", "-1"]], [])
self.check_visit_filtered([["flying_team", str(subject.flying_team.id)]], [self.visit])
def test_visits_filter_default_location(self):
self.check_visit_filtered([["default_location", "-1"]], [])
self.check_visit_filtered([["default_location", str(self.study_subject.default_location.id)]], [self.visit])
def test_visits_filter_is_finished(self):
self.check_visit_filtered([["is_finished", str(not self.visit.is_finished).lower()]], [])
self.check_visit_filtered([["is_finished", str(self.visit.is_finished).lower()]], [self.visit])
def test_visits_filter_post_mail_sent(self):
self.check_visit_filtered([["post_mail_sent", str(not self.visit.post_mail_sent).lower()]], [])
self.check_visit_filtered([["post_mail_sent", str(self.visit.post_mail_sent).lower()]], [self.visit])
def test_visits_filter_visit_number(self):
self.check_visit_filtered([["visit_number", "-1"]], [])
self.check_visit_filtered([["visit_number", str(self.visit.visit_number)]], [self.visit])
def test_visits_filter_visible_appointment_types(self):
appointment_type_1 = create_appointment_type()
appointment_type_2 = create_appointment_type()
self.visit.appointment_types.add(appointment_type_1)
self.visit.save()
self.check_visit_filtered([["visible_appointment_types", str(appointment_type_2.id)]], [])
self.check_visit_filtered([["visible_appointment_types", str(appointment_type_1.id)]], [self.visit])
def test_visits_filter_visible_appointment_types_missing(self):
appointment_type_1 = create_appointment_type()
appointment_type_2 = create_appointment_type()
self.visit.appointment_types.add(appointment_type_1)
self.visit.save()
appointment = create_appointment(self.visit)
AppointmentTypeLink.objects.create(appointment=appointment, appointment_type=appointment_type_2)
self.check_visit_filtered([["visible_appointment_types_missing", str(appointment_type_2.id)]], [])
self.check_visit_filtered([["visible_appointment_types_missing", str(appointment_type_1.id)]], [self.visit])
def test_visits_filter_visible_appointment_types_done(self):
appointment_type_1 = create_appointment_type()
appointment_type_2 = create_appointment_type()
self.visit.appointment_types.add(appointment_type_1)
self.visit.save()
appointment = create_appointment(self.visit)
appointment.status = Appointment.APPOINTMENT_STATUS_FINISHED
appointment.save()
AppointmentTypeLink.objects.create(appointment=appointment, appointment_type=appointment_type_1)
self.check_visit_filtered([["visible_appointment_types_done", str(appointment_type_2.id)]], [])
self.check_visit_filtered([["visible_appointment_types_done", str(appointment_type_1.id)]], [self.visit])
def test_visits_filter_visible_appointment_types_in_progress(self):
appointment_type_1 = create_appointment_type()
appointment_type_2 = create_appointment_type()
self.visit.appointment_types.add(appointment_type_1)
self.visit.save()
appointment = create_appointment(self.visit)
AppointmentTypeLink.objects.create(appointment=appointment, appointment_type=appointment_type_1)
self.check_visit_filtered([["visible_appointment_types_in_progress", str(appointment_type_2.id)]], [])
self.check_visit_filtered([["visible_appointment_types_in_progress", str(appointment_type_1.id)]], [self.visit])
def test_visits_filter_unknown(self):
self.check_visit_filtered([["some_unknown", "unknown data"]], [self.visit])
self.check_visit_filtered([["", ""]], [self.visit])
self.check_visit_filtered([[None, None]], [self.visit])
Loading