From 7ef2d9e7438e9be2d858a4faaf8cbe46d1bec20a Mon Sep 17 00:00:00 2001 From: higs4281 Date: Mon, 29 Feb 2016 11:47:31 -0500 Subject: [PATCH] fix tests if they run on leap day, hereafter called Edgehog Day --- CHANGELOG.md | 3 +++ repositories.yml | 2 +- retirement_api/utils/tests/test_ss_utilities.py | 12 ++++++++---- setup.py | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e0297e..0e93d9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/repositories.yml b/repositories.yml index b304033..b67d652 100644 --- a/repositories.yml +++ b/repositories.yml @@ -1 +1 @@ - project_repository: https://github.com/cfpb/retirement.git@0.4.56 + project_repository: https://github.com/cfpb/retirement.git@0.4.57 diff --git a/retirement_api/utils/tests/test_ss_utilities.py b/retirement_api/utils/tests/test_ss_utilities.py index 79b7063..a2fa7d1 100644 --- a/retirement_api/utils/tests/test_ss_utilities.py +++ b/retirement_api/utils/tests/test_ss_utilities.py @@ -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, @@ -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]) diff --git a/setup.py b/setup.py index 3ef2bb0..23fa0e9 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ def run(self): setup( name='retirement', - version='0.4.56', + version='0.4.57', author='CFPB', author_email='tech@cfpb.gov', maintainer='cfpb',