From 07e71d9ce9ac42ca7f9cb3d33550d619e7f99bdd Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Fri, 20 May 2011 14:18:16 +0100 Subject: [PATCH] Regression test for collection names an primary ordering Closes #91 --- tests/document.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/document.py b/tests/document.py index cef6e8c1..77c8269b 100644 --- a/tests/document.py +++ b/tests/document.py @@ -212,6 +212,22 @@ class DocumentTest(unittest.TestCase): Person.drop_collection() self.assertFalse(collection in self.db.collection_names()) + def test_collection_name_and_primary(self): + """Ensure that a collection with a specified name may be used. + """ + + class Person(Document): + name = StringField(primary_key=True) + meta = {'collection': 'app'} + + user = Person(name="Test User") + user.save() + + user_obj = Person.objects[0] + self.assertEqual(user_obj.name, "Test User") + + Person.drop_collection() + def test_inherited_collections(self): """Ensure that subclassed documents don't override parents' collections. """