Commit cd4cd76e authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch 'fix/registrations-tests' into 'master'

Fix registrations services tests

Closes #553

See merge request !644
parents 93b0cdb8 7db3f70c
......@@ -3,6 +3,7 @@ django-localflavor>=1.4,<1.5
Pillow>=4.1.0,<4.2.0
django-compressor>=2.1,<3
django-sendfile<=0.4
freezegun>=0.3.9,<0.4.0
django-template-check>=0.3.0 # This should be in dev-requirements somehow
bleach>=2.0.0,<2.1
django-tinymce4-lite>=1.5,<1.6
......
......@@ -5,6 +5,7 @@ from django.contrib.auth import get_user_model
from django.core import mail
from django.test import TestCase
from django.utils import timezone
from freezegun import freeze_time
from members.models import Member, Membership
from registrations import services
......@@ -316,9 +317,7 @@ class ServicesTest(TestCase):
self.e2.username = 'ptest'
self.e2.save()
now = timezone.now()
with mock.patch('django.utils.timezone.now') as timezone_mock:
timezone_mock.return_value = now.replace(month=1)
with freeze_time("2017-01-12"):
lecture_year = datetime_to_lectureyear(timezone.now())
m1 = services._create_member_from_registration(self.e1)
......@@ -343,17 +342,17 @@ class ServicesTest(TestCase):
membership2.delete()
with freeze_time("2017-08-12"):
# Check if since is new lecture year in august
timezone_mock.return_value = now.replace(month=8)
membership2 = services._create_membership_from_entry(self.e2, m2)
self.assertEqual(membership2.since, now.date().replace(
self.assertEqual(membership2.since, timezone.now().date().replace(
month=9, day=1))
self.assertEqual(membership2.until, None)
self.assertEqual(membership2.user, m2)
self.assertEqual(membership2.type, self.e2.membership_type)
timezone_mock.return_value = now.replace(month=1)
with freeze_time("2017-01-12"):
# Renewal to new 'study' membership starting today
self.e3.length = Entry.MEMBERSHIP_STUDY
membership3 = services._create_membership_from_entry(self.e3)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment