Added regression test for numerical string keys.
This commit is contained in:
parent
e508625935
commit
3477b0107a
@ -965,6 +965,24 @@ class FieldTest(unittest.TestCase):
|
|||||||
doc = self.db.test.find_one()
|
doc = self.db.test.find_one()
|
||||||
self.assertEqual(doc['x']['DICTIONARY_KEY']['i'], 2)
|
self.assertEqual(doc['x']['DICTIONARY_KEY']['i'], 2)
|
||||||
|
|
||||||
|
def test_mapfield_numerical_index(self):
|
||||||
|
"""Ensure that MapField accept numeric strings as indexes."""
|
||||||
|
class Embedded(EmbeddedDocument):
|
||||||
|
name = StringField()
|
||||||
|
|
||||||
|
class Test(Document):
|
||||||
|
my_map = MapField(EmbeddedDocumentField(Embedded))
|
||||||
|
|
||||||
|
Test.drop_collection()
|
||||||
|
|
||||||
|
test = Test()
|
||||||
|
test.my_map['1'] = Embedded(name='test')
|
||||||
|
test.save()
|
||||||
|
test.my_map['1'].name = 'test updated'
|
||||||
|
test.save()
|
||||||
|
|
||||||
|
Test.drop_collection()
|
||||||
|
|
||||||
def test_map_field_lookup(self):
|
def test_map_field_lookup(self):
|
||||||
"""Ensure MapField lookups succeed on Fields without a lookup method"""
|
"""Ensure MapField lookups succeed on Fields without a lookup method"""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user