Embedded Documents still can inherit fields MongoEngine/mongoengine#84

This commit is contained in:
Ross Lawley
2012-08-22 09:27:18 +01:00
parent bb1b9bc1d3
commit 0526f577ff
2 changed files with 29 additions and 8 deletions

View File

@@ -2585,6 +2585,21 @@ class DocumentTest(unittest.TestCase):
Person.drop_collection()
def test_object_mixins(self):
class NameMixin(object):
name = StringField()
class Foo(EmbeddedDocument, NameMixin):
quantity = IntField()
self.assertEqual(['name', 'quantity'], sorted(Foo._fields.keys()))
class Bar(Document, NameMixin):
widgets = StringField()
self.assertEqual(['id', 'name', 'widgets'], sorted(Bar._fields.keys()))
def test_mixin_inheritance(self):
class BaseMixIn(object):
count = IntField()