Multiple fields with the same db_field now raises Exception

Closes #329
This commit is contained in:
Ross Lawley
2011-12-02 08:44:15 -08:00
parent 9bfc838029
commit 700bc1b4bb
4 changed files with 19 additions and 1 deletions

View File

@@ -2182,6 +2182,16 @@ class DocumentTest(unittest.TestCase):
BlogPost.drop_collection()
def test_duplicate_db_fields_raise_invalid_document_error(self):
"""Ensure a InvalidDocumentError is thrown if duplicate fields
declare the same db_field"""
def throw_invalid_document_error():
class Foo(Document):
name = StringField()
name2 = StringField(db_field='name')
self.assertRaises(InvalidDocumentError, throw_invalid_document_error)
def test_reverse_delete_rule_cascade_and_nullify(self):
"""Ensure that a referenced document is also deleted upon deletion.