Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Commit

Permalink
fix tests if they run on leap day, hereafter called Edgehog Day
Browse files Browse the repository at this point in the history
  • Loading branch information
higs4281 committed Feb 29, 2016
1 parent a45bbbb commit 7ef2d9e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Notable changes to this project will be documented in this file.
We follow the [Semantic Versioning 2.0.0](http://semver.org/) format.

## 0.4.57
- fix tests should they happen to run on leap day (Edgehog Day)

## 0.4.56
- fix prorating in edge cases

Expand Down
2 changes: 1 addition & 1 deletion repositories.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
project_repository: https://github.com/cfpb/[email protected].56
project_repository: https://github.com/cfpb/[email protected].57
12 changes: 8 additions & 4 deletions retirement_api/utils/tests/test_ss_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

class UtilitiesTests(unittest.TestCase):
today = datetime.date.today()
if today.day == 29:
today = today.replace(day=today.day - 1)
sample_params = {
'dobmon': 1,
'dobday': 1,
Expand Down Expand Up @@ -53,23 +55,25 @@ def test_months_past_birthday(self):

def test_months_until_next_bday(self):
age40 = self.today.replace(year=(self.today.year - 40))
bd_one_day_later = age40 + datetime.timedelta(days=1)
bd_two_days_later = age40 + datetime.timedelta(days=2)
bd_month_later = age40 + datetime.timedelta(days=30)
diff1 = get_months_until_next_birthday(age40)
diff2 = get_months_until_next_birthday(bd_one_day_later)
diff2 = get_months_until_next_birthday(bd_two_days_later)
diff3 = get_months_until_next_birthday(bd_month_later)
self.assertTrue(diff1 == 12)
self.assertTrue(diff2 in [0, 1])
self.assertTrue(diff3 in [1, 2])

def test_get_current_age(self):
if self.today.day == 29:
self.today.day = self.today.day -1
age_pairs = [(self.today.replace(year=self.today.year - 1), 1),
('{0}'.format(self.today.replace(year=self.today.year - 1)), 1),
(self.today.replace(year=self.today.year - 20), 20),
(self.today.replace(year=self.today.year - 60), 60),
(self.today, None),
(self.today, 0),
('xx', None),
(self.today + datetime.timedelta(days=1), None)]
(self.today + datetime.timedelta(days=2), None)]
for pair in age_pairs:
self.assertEqual(get_current_age(pair[0]), pair[1])

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def run(self):

setup(
name='retirement',
version='0.4.56',
version='0.4.57',
author='CFPB',
author_email='[email protected]',
maintainer='cfpb',
Expand Down

0 comments on commit 7ef2d9e

Please sign in to comment.