commit
7da3ce6d56
|
@ -1,7 +1,3 @@
|
||||||
import django, sys, os
|
|
||||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'apiserver.settings'
|
|
||||||
django.setup()
|
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
import datetime
|
import datetime
|
||||||
from dateutil import relativedelta
|
from dateutil import relativedelta
|
||||||
|
@ -9,12 +5,6 @@ from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
from apiserver.api import utils, utils_paypal, models
|
from apiserver.api import utils, utils_paypal, models
|
||||||
|
|
||||||
testing_member, _ = models.Member.objects.get_or_create(
|
|
||||||
first_name='unittest',
|
|
||||||
preferred_name='unittest',
|
|
||||||
last_name='tester',
|
|
||||||
)
|
|
||||||
|
|
||||||
class TestMonthsSpanned(TestCase):
|
class TestMonthsSpanned(TestCase):
|
||||||
def test_num_months_spanned_one_month(self):
|
def test_num_months_spanned_one_month(self):
|
||||||
date2 = datetime.date(2020, 1, 10)
|
date2 = datetime.date(2020, 1, 10)
|
||||||
|
@ -200,45 +190,28 @@ class TestCalcStatus(TestCase):
|
||||||
self.assertEqual(status, 'Former Member')
|
self.assertEqual(status, 'Former Member')
|
||||||
|
|
||||||
|
|
||||||
class TestFakeMonths(TestCase):
|
|
||||||
def test_fake_missing_membership_months_one_month(self):
|
|
||||||
testing_member.current_start_date = datetime.date(2018, 6, 6)
|
|
||||||
testing_member.expire_date = datetime.date(2018, 7, 6)
|
|
||||||
|
|
||||||
tx, count = utils.fake_missing_membership_months(testing_member)
|
|
||||||
|
|
||||||
self.assertEqual(count, 1)
|
|
||||||
|
|
||||||
def test_fake_missing_membership_months_one_and_half_month(self):
|
|
||||||
testing_member.current_start_date = datetime.date(2018, 6, 1)
|
|
||||||
testing_member.expire_date = datetime.date(2018, 7, 15)
|
|
||||||
|
|
||||||
tx, count = utils.fake_missing_membership_months(testing_member)
|
|
||||||
|
|
||||||
self.assertEqual(count, 1)
|
|
||||||
|
|
||||||
def test_fake_missing_membership_months_one_year(self):
|
|
||||||
testing_member.current_start_date = datetime.date(2018, 6, 6)
|
|
||||||
testing_member.expire_date = datetime.date(2019, 6, 6)
|
|
||||||
|
|
||||||
tx, count = utils.fake_missing_membership_months(testing_member)
|
|
||||||
|
|
||||||
self.assertEqual(count, 12)
|
|
||||||
|
|
||||||
def test_fake_missing_membership_months_same_month(self):
|
|
||||||
testing_member.current_start_date = datetime.date(2018, 6, 6)
|
|
||||||
testing_member.expire_date = datetime.date(2018, 6, 16)
|
|
||||||
|
|
||||||
tx, count = utils.fake_missing_membership_months(testing_member)
|
|
||||||
|
|
||||||
self.assertEqual(count, 0)
|
|
||||||
|
|
||||||
|
|
||||||
class TestTallyMembership(TestCase):
|
class TestTallyMembership(TestCase):
|
||||||
|
def get_user(self):
|
||||||
|
testing_user, _ = models.User.objects.get_or_create(
|
||||||
|
first_name='unittest',
|
||||||
|
username='unittest',
|
||||||
|
last_name='tester',
|
||||||
|
email='unittest@unittest.com'
|
||||||
|
)
|
||||||
|
return testing_user
|
||||||
|
|
||||||
def get_member_clear_transactions(self):
|
def get_member_clear_transactions(self):
|
||||||
member = testing_member
|
testing_user = self.get_user()
|
||||||
member.paused_date = None
|
|
||||||
member.expire_date = None
|
member, _ = models.Member.objects.get_or_create(
|
||||||
|
first_name=testing_user.first_name,
|
||||||
|
preferred_name=testing_user.first_name,
|
||||||
|
last_name=testing_user.last_name,
|
||||||
|
user=testing_user,
|
||||||
|
paused_date=None,
|
||||||
|
expire_date=None
|
||||||
|
)
|
||||||
|
|
||||||
return member
|
return member
|
||||||
|
|
||||||
def test_tally_membership_months_prepaid(self):
|
def test_tally_membership_months_prepaid(self):
|
||||||
|
@ -254,6 +227,7 @@ class TestTallyMembership(TestCase):
|
||||||
models.Transaction.objects.create(
|
models.Transaction.objects.create(
|
||||||
amount=0,
|
amount=0,
|
||||||
member_id=member.id,
|
member_id=member.id,
|
||||||
|
user=member.user,
|
||||||
number_of_membership_months=1,
|
number_of_membership_months=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -275,6 +249,7 @@ class TestTallyMembership(TestCase):
|
||||||
models.Transaction.objects.create(
|
models.Transaction.objects.create(
|
||||||
amount=0,
|
amount=0,
|
||||||
member_id=member.id,
|
member_id=member.id,
|
||||||
|
user=member.user,
|
||||||
number_of_membership_months=1,
|
number_of_membership_months=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -296,6 +271,7 @@ class TestTallyMembership(TestCase):
|
||||||
models.Transaction.objects.create(
|
models.Transaction.objects.create(
|
||||||
amount=0,
|
amount=0,
|
||||||
member_id=member.id,
|
member_id=member.id,
|
||||||
|
user=member.user,
|
||||||
number_of_membership_months=1,
|
number_of_membership_months=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -317,6 +293,7 @@ class TestTallyMembership(TestCase):
|
||||||
models.Transaction.objects.create(
|
models.Transaction.objects.create(
|
||||||
amount=0,
|
amount=0,
|
||||||
member_id=member.id,
|
member_id=member.id,
|
||||||
|
user=member.user,
|
||||||
number_of_membership_months=1,
|
number_of_membership_months=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -338,6 +315,7 @@ class TestTallyMembership(TestCase):
|
||||||
models.Transaction.objects.create(
|
models.Transaction.objects.create(
|
||||||
amount=0,
|
amount=0,
|
||||||
member_id=member.id,
|
member_id=member.id,
|
||||||
|
user=member.user,
|
||||||
number_of_membership_months=1,
|
number_of_membership_months=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user