From a5eefcf5c0b9af96ddea98590aa913a9fb0e9f42 Mon Sep 17 00:00:00 2001 From: Kent Brockman Date: Sat, 25 Jun 2022 19:09:58 -0700 Subject: [PATCH 1/3] test: remove testcase for method that no longer exists --- apiserver/apiserver/api/tests.py | 34 -------------------------------- 1 file changed, 34 deletions(-) diff --git a/apiserver/apiserver/api/tests.py b/apiserver/apiserver/api/tests.py index ea57855..229ff20 100644 --- a/apiserver/apiserver/api/tests.py +++ b/apiserver/apiserver/api/tests.py @@ -200,40 +200,6 @@ class TestCalcStatus(TestCase): 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): def get_member_clear_transactions(self): member = testing_member From c029f1ab38db1c83ca7427b064dcad9a30ca17cb Mon Sep 17 00:00:00 2001 From: Kent Brockman Date: Sun, 26 Jun 2022 08:12:20 -0700 Subject: [PATCH 2/3] test: move test user/member data creation into testing context --- apiserver/apiserver/api/tests.py | 34 +++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/apiserver/apiserver/api/tests.py b/apiserver/apiserver/api/tests.py index 229ff20..5f5faa6 100644 --- a/apiserver/apiserver/api/tests.py +++ b/apiserver/apiserver/api/tests.py @@ -9,12 +9,6 @@ from rest_framework.exceptions import ValidationError 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): def test_num_months_spanned_one_month(self): date2 = datetime.date(2020, 1, 10) @@ -201,10 +195,27 @@ class TestCalcStatus(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): - member = testing_member - member.paused_date = None - member.expire_date = None + testing_user = self.get_user() + + 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 def test_tally_membership_months_prepaid(self): @@ -220,6 +231,7 @@ class TestTallyMembership(TestCase): models.Transaction.objects.create( amount=0, member_id=member.id, + user=member.user, number_of_membership_months=1, ) @@ -241,6 +253,7 @@ class TestTallyMembership(TestCase): models.Transaction.objects.create( amount=0, member_id=member.id, + user=member.user, number_of_membership_months=1, ) @@ -262,6 +275,7 @@ class TestTallyMembership(TestCase): models.Transaction.objects.create( amount=0, member_id=member.id, + user=member.user, number_of_membership_months=1, ) @@ -283,6 +297,7 @@ class TestTallyMembership(TestCase): models.Transaction.objects.create( amount=0, member_id=member.id, + user=member.user, number_of_membership_months=1, ) @@ -304,6 +319,7 @@ class TestTallyMembership(TestCase): models.Transaction.objects.create( amount=0, member_id=member.id, + user=member.user, number_of_membership_months=1, ) From f76e0953ed04a2622ee03c802df2e099ef15c7f2 Mon Sep 17 00:00:00 2001 From: Kent Brockman Date: Sun, 26 Jun 2022 08:14:21 -0700 Subject: [PATCH 3/3] test: remove unused django setup calls --- apiserver/apiserver/api/tests.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apiserver/apiserver/api/tests.py b/apiserver/apiserver/api/tests.py index 5f5faa6..6f045b7 100644 --- a/apiserver/apiserver/api/tests.py +++ b/apiserver/apiserver/api/tests.py @@ -1,7 +1,3 @@ -import django, sys, os -os.environ['DJANGO_SETTINGS_MODULE'] = 'apiserver.settings' -django.setup() - from django.test import TestCase import datetime from dateutil import relativedelta