Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Merge 107d9a3 into 23b8f41
Browse files Browse the repository at this point in the history
  • Loading branch information
lafrech committed Jun 16, 2016
2 parents 23b8f41 + 107d9a3 commit 6a2c1dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion marshmallow_mongoengine/fields.py
Expand Up @@ -28,7 +28,7 @@ def _deserialize(self, value, attr, data):
try:
return dict(
type='Point',
coordinates=[value['x'], value['y']]
coordinates=[float(value['x']), float(value['y'])]
)
except:
raise ValidationError('invalid Point `%s`' % value)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_fields.py
Expand Up @@ -289,4 +289,13 @@ class Meta:
dump = DocSchema().dump(doc)
assert not dump.errors
assert dump.data['point'] == { 'x': 10, 'y': 20 }
load = DocSchema().load(dump.data)
assert not load.errors
assert load.data.point == { 'type': 'Point', 'coordinates': [10, 20] }
# Deserialize Point with coordinates passed as string
data = {'point': { 'x': '10', 'y': '20' }}
load = DocSchema().load(data)
assert not load.errors
assert load.data.point == { 'type': 'Point', 'coordinates': [10, 20] }


0 comments on commit 6a2c1dd

Please sign in to comment.