added CachedReferenceField restriction to use in EmbeddedDocument

This commit is contained in:
Wilson Júnior
2014-07-17 13:42:34 -03:00
parent 73549a9044
commit 6c4aee1479
3 changed files with 38 additions and 15 deletions

View File

@@ -1539,6 +1539,18 @@ class FieldTest(unittest.TestCase):
self.assertEqual(ocorrence.person, "teste")
self.assertTrue(isinstance(ocorrence.animal, Animal))
def test_cached_reference_fields_on_embedded_documents(self):
def build():
class Test(Document):
name = StringField()
type('WrongEmbeddedDocument', (
EmbeddedDocument,), {
'test': CachedReferenceField(Test)
})
self.assertRaises(InvalidDocumentError, build)
def test_cached_reference_embedded_fields(self):
class Owner(EmbeddedDocument):
TPS = (