diff --git a/smash/web/tests/test_view_notifications.py b/smash/web/tests/test_view_notifications.py index 817ec07cb60733cefdd4b41da16c009d3c16d06f..805c95ec772dbe7aa42cd37dfc710ad3e8213447 100644 --- a/smash/web/tests/test_view_notifications.py +++ b/smash/web/tests/test_view_notifications.py @@ -1,6 +1,6 @@ import datetime -from django.contrib.auth.models import User +from django.contrib.auth.models import AnonymousUser, User from django.test import TestCase, RequestFactory from functions import create_appointment, create_location, create_worker, create_appointment_type @@ -13,6 +13,7 @@ from web.views.notifications import \ get_approaching_visits_without_appointments, \ get_approaching_visits_without_appointments_count, \ get_exceeded_visit_notifications_count, \ + get_filter_locations, \ get_notifications, \ get_subject_with_no_visit_notifications_count, \ get_subjects_with_reminder_count, \ @@ -21,7 +22,7 @@ from web.views.notifications import \ get_today_midnight_date, \ get_unfinished_appointments, \ get_unfinished_appointments_count, \ - get_unfinished_visits, get_active_visits_with_missing_appointments + get_unfinished_visits class NotificationViewTests(TestCase): @@ -85,7 +86,7 @@ class NotificationViewTests(TestCase): appointment = create_appointment(visit) appointment.appointment_types.add(appointment_type) - appointment.status=Appointment.APPOINTMENT_STATUS_FINISHED + appointment.status = Appointment.APPOINTMENT_STATUS_FINISHED appointment.save() notification = get_visits_with_missing_appointments_count(self.user) @@ -426,3 +427,14 @@ class NotificationViewTests(TestCase): notification = get_subject_with_no_visit_notifications_count(self.user) self.assertEquals(original_without_visit_notification.count, notification.count) + + def test_get_filter_locations_for_invalid_user(self): + locations = get_filter_locations(AnonymousUser()) + self.assertEqual(0, locations.count()) + + def test_get_filter_locations_for_invalid_user_2(self): + try: + locations = get_filter_locations("invalid class") + self.fail("Exception expected") + except TypeError: + pass