added test for abstract document without pk creation and adapted behaviour

This commit is contained in:
mrigal
2015-04-16 14:33:16 +02:00
committed by Matthieu Rigal
parent 8909d1d144
commit 1862bcf867
3 changed files with 14 additions and 1 deletions

View File

@@ -307,6 +307,17 @@ class InheritanceTest(unittest.TestCase):
doc = Animal(name='dog')
self.assertFalse('_cls' in doc.to_mongo())
def test_abstract_document_creation_does_not_fail(self):
class City(Document):
continent = StringField()
meta = {'abstract': True,
'allow_inheritance': False}
bkk = City(continent='asia')
self.assertEqual(None, bkk.pk)
# TODO: expected error? Shouldn'twe created a new error type
self.assertRaises(KeyError, lambda: setattr(bkk, 'pk', 1))
def test_allow_inheritance_embedded_document(self):
"""Ensure embedded documents respect inheritance
"""