|
@@ -9,6 +9,7 @@ from cStringIO import StringIO
|
|
|
from dateutil.relativedelta import relativedelta
|
|
|
from freezegun import freeze_time
|
|
|
import unittest
|
|
|
+from freezegun import freeze_time
|
|
|
|
|
|
from django import db
|
|
|
from django.conf import settings
|
|
@@ -17,6 +18,7 @@ from django.core import mail, management
|
|
|
from django.core.exceptions import ValidationError
|
|
|
|
|
|
from coin.members.models import Member, MembershipFee, LdapUser
|
|
|
+from coin.offers.models import OfferSubscription, Offer
|
|
|
from coin.validation import chatroom_url_validator
|
|
|
|
|
|
|
|
@@ -509,6 +511,52 @@ class MemberTestCallForMembershipCommand(TestCase):
|
|
|
self.do_test_email_sent(0)
|
|
|
|
|
|
|
|
|
+class MemberManagerTest(TestCase):
|
|
|
+ def setUp(self):
|
|
|
+ self.ab = Member.objects.create(
|
|
|
+ first_name='a', last_name='b', username='ab', email='ab@ex.com')
|
|
|
+ self.cd = Member.objects.create(
|
|
|
+ first_name='c', last_name='d', username='cd', email='cd@ex.com')
|
|
|
+ self.ef = Member.objects.create(
|
|
|
+ first_name='e', last_name='f', username='ef', email='ef@ex.com')
|
|
|
+ self.gh = Member.objects.create(
|
|
|
+ first_name='g', last_name='h', username='gh', email='gh@ex.com')
|
|
|
+
|
|
|
+ MembershipFee.objects.create(member=self.ab, amount=20,
|
|
|
+ start_date=date(2015, 11, 11),
|
|
|
+ end_date=date(2016, 11, 11))
|
|
|
+
|
|
|
+ MembershipFee.objects.create(member=self.cd, amount=20,
|
|
|
+ start_date=date(2016, 1, 1),
|
|
|
+ end_date=date(2016, 1, 1))
|
|
|
+
|
|
|
+ OfferSubscription.objects.create(
|
|
|
+ subscription_date=date(2016, 2, 2),
|
|
|
+ member=self.ef,
|
|
|
+ offer=Offer.objects.create(
|
|
|
+ name='fu',
|
|
|
+ period_fees=0,
|
|
|
+ initial_fees=0
|
|
|
+ ),
|
|
|
+ )
|
|
|
+
|
|
|
+ @freeze_time('2016-10-01')
|
|
|
+ def test_could_be_deleted(self):
|
|
|
+ deletion_set = set(Member.objects.could_be_deleted())
|
|
|
+
|
|
|
+ # late on fee (-> delete)
|
|
|
+ self.assertIn(self.cd, deletion_set)
|
|
|
+
|
|
|
+ # no fee at all (-> delete)
|
|
|
+ self.assertIn(self.gh, deletion_set)
|
|
|
+
|
|
|
+ # running fee (-> no delete)
|
|
|
+ self.assertNotIn(self.ab, deletion_set)
|
|
|
+
|
|
|
+ # running service (even if no fee) (-> no delete)
|
|
|
+ self.assertNotIn(self.ef, deletion_set)
|
|
|
+
|
|
|
+
|
|
|
class MemberTestsUtils(object):
|
|
|
|
|
|
@staticmethod
|