Skip to content

Commit

Permalink
Set birth year given multiple formats (#201)
Browse files Browse the repository at this point in the history
* Add test case for birth year 'mm/dd/yyyy' format

When the user searches for a record passing in the birth date format
then the response returned also includes that birth date instead of the
default value (birth year).

* Set birth year with different date formats

Split argument on '/' and assign the birth year only.

Fixes #200
  • Loading branch information
NickSchimek authored Jun 13, 2019
1 parent 2acee99 commit f28103b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/backend/expungeservice/models/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ def closed(self):
@staticmethod
def _set_birth_year(info):
if len(info) > 1:
return int(info[1])
return int(info[1].split('/')[-1])
else:
return ''
15 changes: 14 additions & 1 deletion src/backend/tests/models/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def test_it_returns_true_for_an_inactive_case(self):
assert self.case.closed() is True


class TestBirthYearDefaultValue(unittest.TestCase):
class TestBirthYearInitializesGivenMultipleValues(unittest.TestCase):

def setUp(self):
self.case = CaseFactory.build()

Expand All @@ -51,3 +52,15 @@ def test_birth_year_defaults_to_empty_string(self):
case = CaseFactory.save(self.case)

assert case.birth_year == ''

def test_it_assigns_birth_year_when_given_the_year(self):
self.case['info'] = ['John Doe', '1979']
case = CaseFactory.save(self.case)

assert case.birth_year == 1979

def test_it_assigns_birth_year_when_given_the_month_day_year_format(self):
self.case['info'] = ['John Doe', '12/21/1979']
case = CaseFactory.save(self.case)

assert case.birth_year == 1979

0 comments on commit f28103b

Please sign in to comment.