From fb61c9a765d0605a27f720d7a24d43aa580e109b Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Thu, 19 May 2011 09:55:34 +0100 Subject: [PATCH] Regression test for mysterious uniqueness constraint when inserting into mongoengine Closes #143 Thanks to tfausak for the test case. --- tests/document.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/document.py b/tests/document.py index dee0b712..f6d8ea49 100644 --- a/tests/document.py +++ b/tests/document.py @@ -798,6 +798,25 @@ class DocumentTest(unittest.TestCase): self.Person.drop_collection() BlogPost.drop_collection() + def subclasses_and_unique_keys_works(self): + + class A(Document): + pass + + class B(A): + foo = BooleanField(unique=True) + + A.drop_collection() + B.drop_collection() + + A().save() + A().save() + B(foo=True).save() + + self.assertEquals(A.objects.count(), 2) + self.assertEquals(B.objects.count(), 1) + A.drop_collection() + B.drop_collection() def tearDown(self): self.Person.drop_collection()