diff --git a/apiserver/apiserver/api/tests.py b/apiserver/apiserver/api/tests.py index 58cd3ae..0dbf861 100644 --- a/apiserver/apiserver/api/tests.py +++ b/apiserver/apiserver/api/tests.py @@ -143,9 +143,10 @@ class TestCalcStatus(TestCase): self.assertEqual(former, False) def test_calc_member_status_1_month(self): - expire_date = utils.today_alberta_tz() + relativedelta.relativedelta(months=1) + today = datetime.date(2019, 2, 10) + expire_date = datetime.date(2019, 3, 10) - status, former = utils.calc_member_status(expire_date) + status, former = utils.calc_member_status(expire_date, today) self.assertEqual(status, 'Current') self.assertEqual(former, False) @@ -182,6 +183,15 @@ class TestCalcStatus(TestCase): self.assertEqual(status, 'Due') self.assertEqual(former, False) + def test_calc_member_status_1_month_ago(self): + today = datetime.date(2019, 4, 10) + expire_date = datetime.date(2019, 3, 10) + + status, former = utils.calc_member_status(expire_date, today) + + self.assertEqual(status, 'Overdue') + self.assertEqual(former, False) + def test_calc_member_status_85_days_ago(self): expire_date = utils.today_alberta_tz() - datetime.timedelta(days=85) diff --git a/apiserver/apiserver/api/utils.py b/apiserver/apiserver/api/utils.py index 0ac90fc..25db660 100644 --- a/apiserver/apiserver/api/utils.py +++ b/apiserver/apiserver/api/utils.py @@ -56,7 +56,7 @@ def calc_member_status(expire_date, fake_date=None): return 'Prepaid', False elif difference <= -3: return 'Overdue', True - elif difference <= -1: + elif today - timedelta(days=29) >= expire_date: return 'Overdue', False elif today < expire_date: return 'Current', False