Skip to content

Commit

Permalink
Don't present integer k/v items as floats (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavius authored Jun 10, 2020
1 parent 140bfba commit cebd7d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ def test_emd_values(self):
item = {
item_key: {
'age': 42,
'pi': 3.14,
'feature': 'mustache',
'male': True,
'happy': False,
Expand All @@ -350,6 +351,9 @@ def test_emd_values(self):

self.assertEqual(item[item_key], response.output.item)

for key, value in item[item_key].items():
self.assertEqual(type(value), type(response.output.item[key]))

def test_emd(self):
items = {
'bob': {'age': 42, 'feature': 'mustache'},
Expand Down
7 changes: 6 additions & 1 deletion v3io/dataplane/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ def _decode_typed_attributes(self, typed_attributes):
for attribute_key, typed_attribute_value in future.utils.viewitems(typed_attributes):
for attribute_type, attribute_value in future.utils.viewitems(typed_attribute_value):
if attribute_type == 'N':
decoded_attribute = float(attribute_value)
try:
decoded_attribute = int(attribute_value)
except ValueError:
decoded_attribute = float(attribute_value)
elif attribute_type == 'B':
decoded_attribute = base64.b64decode(attribute_value)
elif attribute_type == 'S':
decoded_attribute = str(attribute_value)
else:
decoded_attribute = attribute_value

Expand Down

0 comments on commit cebd7d9

Please sign in to comment.