diff --git a/smash/web/tests/functions.py b/smash/web/tests/functions.py index 52ba55dfdfa75cfec5161885500b5294244371a4..db0e29df574fecd2fd9f4acc2a4f3d51b957a44c 100644 --- a/smash/web/tests/functions.py +++ b/smash/web/tests/functions.py @@ -6,7 +6,7 @@ from django.contrib.auth.models import User from web.models import Location, AppointmentType, StudySubject, Worker, Visit, Appointment, ConfigurationItem, \ Language, ContactAttempt, FlyingTeam, Availability, Subject, Study, StudyColumns, StudyNotificationParameters, \ - VoucherType, VoucherTypePrice + VoucherType, VoucherTypePrice, Voucher from web.models.constants import REDCAP_TOKEN_CONFIGURATION_TYPE, REDCAP_BASE_URL_CONFIGURATION_TYPE, \ SEX_CHOICES_MALE, SUBJECT_TYPE_CHOICES_CONTROL, CONTACT_TYPES_PHONE, \ MONDAY_AS_DAY_OF_WEEK, COUNTRY_AFGHANISTAN_ID @@ -67,7 +67,17 @@ def create_study(name="test"): return Study.objects.create(name=name, columns=study_columns, notification_parameters=notification_parameters) -def create_empty_notification_parametres(): +def create_voucher(study_subject=None): + if study_subject is None: + study_subject = create_study_subject() + return Voucher.objects.create(number="123456", + study_subject=study_subject, + issue_date=get_today_midnight_date(), + expiry_date=get_today_midnight_date(), + voucher_type=create_voucher_type()) + + +def create_empty_notification_parameters(): return StudyNotificationParameters.objects.create( exceeded_visits_visible=False, unfinished_visits_visible=False, @@ -84,7 +94,7 @@ def create_empty_notification_parametres(): def create_empty_study(name="test"): study_columns = create_empty_study_columns() - notification_parameters = create_empty_notification_parametres() + notification_parameters = create_empty_notification_parameters() result = create_study(name) result.columns = study_columns result.notification_parameters = notification_parameters diff --git a/smash/web/tests/models/test_voucher.py b/smash/web/tests/models/test_voucher.py new file mode 100644 index 0000000000000000000000000000000000000000..ec5e94316c2bda04dd70bb337498063ff4decca8 --- /dev/null +++ b/smash/web/tests/models/test_voucher.py @@ -0,0 +1,15 @@ +import logging + +from django.test import TestCase + +from web.tests.functions import create_voucher + +logger = logging.getLogger(__name__) + + +class VoucherTests(TestCase): + def test_to_string(self): + voucher = create_voucher() + + self.assertTrue(voucher.number in str(voucher)) + self.assertTrue(voucher.number in unicode(voucher)) diff --git a/smash/web/tests/view/test_notifications.py b/smash/web/tests/view/test_notifications.py index e02b515089640176d13e3b57c13c0b7a902a64b8..e84952c33c2207af6c1c65c0e505da4768e0d876 100644 --- a/smash/web/tests/view/test_notifications.py +++ b/smash/web/tests/view/test_notifications.py @@ -7,7 +7,7 @@ from web.models import Appointment, Location, AppointmentTypeLink, Study, Visit from web.models.constants import GLOBAL_STUDY_ID from web.tests import LoggedInTestCase from web.tests.functions import create_appointment, create_location, create_worker, create_appointment_type, \ - create_empty_notification_parametres, create_study_subject, create_visit + create_empty_notification_parameters, create_study_subject, create_visit from web.views.notifications import \ get_approaching_visits_for_mail_contact, \ get_approaching_visits_for_mail_contact_count, \ @@ -118,7 +118,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_notifications_with_empty_study_notification(self): study = Study.objects.filter(id=GLOBAL_STUDY_ID)[0] - study.notification_parameters = create_empty_notification_parametres() + study.notification_parameters = create_empty_notification_parameters() study.save() create_worker(self.user)