one more test
This commit is contained in:
parent
4631b75553
commit
2d9e21f639
@ -1884,8 +1884,8 @@ class FieldTest(MongoDBTestCase):
|
|||||||
self.assertEqual(doc['x']['i'], 2)
|
self.assertEqual(doc['x']['i'], 2)
|
||||||
|
|
||||||
def test_double_embedded_db_field(self):
|
def test_double_embedded_db_field(self):
|
||||||
"""Make sure that multiple layers of embedded fields resolve db
|
"""Make sure multiple layers of embedded docs resolve db fields
|
||||||
fields properly and can be initialized using dicts.
|
properly and can be initialized using dicts.
|
||||||
"""
|
"""
|
||||||
class C(EmbeddedDocument):
|
class C(EmbeddedDocument):
|
||||||
txt = StringField()
|
txt = StringField()
|
||||||
@ -1906,6 +1906,28 @@ class FieldTest(MongoDBTestCase):
|
|||||||
a = A(b={'c': {'txt': 'hi'}})
|
a = A(b={'c': {'txt': 'hi'}})
|
||||||
a.validate()
|
a.validate()
|
||||||
|
|
||||||
|
def test_double_embedded_db_field_from_son(self):
|
||||||
|
"""Make sure multiple layers of embedded docs resolve db fields
|
||||||
|
from SON properly.
|
||||||
|
"""
|
||||||
|
class C(EmbeddedDocument):
|
||||||
|
txt = StringField()
|
||||||
|
|
||||||
|
class B(EmbeddedDocument):
|
||||||
|
c = EmbeddedDocumentField(C, db_field='fc')
|
||||||
|
|
||||||
|
class A(Document):
|
||||||
|
b = EmbeddedDocumentField(B, db_field='fb')
|
||||||
|
|
||||||
|
a = A._from_son(SON([
|
||||||
|
('fb', SON([
|
||||||
|
('fc', SON([
|
||||||
|
('txt', 'hi')
|
||||||
|
]))
|
||||||
|
]))
|
||||||
|
]))
|
||||||
|
self.assertEqual(a.b.c.txt, 'hi')
|
||||||
|
|
||||||
def test_embedded_document_validation(self):
|
def test_embedded_document_validation(self):
|
||||||
"""Ensure that invalid embedded documents cannot be assigned to
|
"""Ensure that invalid embedded documents cannot be assigned to
|
||||||
embedded document fields.
|
embedded document fields.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user