Added basic querying - find and find_one

This commit is contained in:
Harry Marr
2009-11-19 01:09:58 +00:00
parent 94be32b387
commit 8ec6fecd23
7 changed files with 141 additions and 12 deletions

View File

@@ -103,6 +103,24 @@ class FieldTest(unittest.TestCase):
person.preferences = PersonPreferences(food='Cheese', number=47)
self.assertEqual(person.preferences.food, 'Cheese')
def test_embedded_document_inheritance(self):
"""Ensure that subclasses of embedded documents may be provided to
EmbeddedDocumentFields of the superclass' type.
"""
class User(EmbeddedDocument):
name = StringField()
class PowerUser(User):
power = IntField()
class BlogPost(Document):
content = StringField()
author = EmbeddedDocumentField(User)
post = BlogPost(content='What I did today...')
post.author = User(name='Test User')
post.author = PowerUser(name='Test User', power=47)
if __name__ == '__main__':
unittest.main()