From fedc06806dbe01b43faf5cd42bbc7f8a6375a4a1 Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Wed, 12 Mar 2014 13:48:49 -0400 Subject: [PATCH] Test schema is set in each collection --- .../tests/test_split_modulestore.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py index 91437bd804..6ca20190bc 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py @@ -18,6 +18,7 @@ from xmodule.modulestore.inheritance import InheritanceMixin from xmodule.x_module import XModuleMixin from xmodule.fields import Date, Timedelta from bson.objectid import ObjectId +from xmodule.modulestore.split_mongo.split import SplitMongoModuleStore class SplitModuleTest(unittest.TestCase): @@ -1625,6 +1626,26 @@ class TestPublish(SplitModuleTest): dest_cursor += 1 self.assertEqual(dest_cursor, len(dest_children)) +class TestSchema(SplitModuleTest): + """ + Test the db schema (and possibly eventually migrations?) + """ + def test_schema(self): + """ + Test that the schema is set in each document + """ + db_connection = modulestore().db_connection + for collection in [db_connection.course_index, db_connection.structures, db_connection.definitions]: + self.assertEqual( + collection.find({'schema_version': {'$exists': False}}).count(), + 0, + "{0.name} has records without schema_version".format(collection) + ) + self.assertEqual( + collection.find({'schema_version': {'$ne': SplitMongoModuleStore.SCHEMA_VERSION}}).count(), + 0, + "{0.name} has records with wrong schema_version".format(collection) + ) #=========================================== def modulestore():