Skip to content

Commit

Permalink
Merge pull request #119 from mikeywaites/feature/fix-int-cast
Browse files Browse the repository at this point in the history
fix int casting
  • Loading branch information
mikeywaites authored Aug 16, 2016
2 parents 7a5323d + 686885b commit 5e77f09
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0-rc3
1.0.0-rc4
3 changes: 2 additions & 1 deletion kim/pipelines/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ def is_valid_integer(session):
"""

try:
return int(session.data)
session.data = int(session.data)
except TypeError:
raise session.field.invalid(error_type='type_error')
except ValueError:
raise session.field.invalid(error_type='type_error')
return session.data


@pipe()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PyTest(TestCommand):

def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = ['-x', '-s']
self.test_args = ['-s']
self.test_suite = True

def run_tests(self):
Expand Down
10 changes: 10 additions & 0 deletions tests/test_pipelines/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def test_integer_input():
field.marshal(mapper_session)
assert output == {'name': 2}

output = {}
mapper_session = get_mapper_session(
data={'name': '2', 'email': 'mike@mike.com'}, output=output)
field.marshal(mapper_session)
assert output == {'name': 2}


def test_integer_field_invalid_type():

Expand Down Expand Up @@ -122,6 +128,10 @@ def test_min_max():
field.marshal(mapper_session)
assert output == {'age': 25}

mapper_session = get_mapper_session(data={'age': '25'}, output=output)
field.marshal(mapper_session)
assert output == {'age': 25}


def test_is_valid_decimal_pipe():
"""test piping data through is_valid_decimal.
Expand Down

0 comments on commit 5e77f09

Please sign in to comment.