From 478f3cc8aa8cc4cd3bfe4e4aa417da6c9b16f79f Mon Sep 17 00:00:00 2001 From: cahrens Date: Mon, 19 Aug 2013 15:38:27 -0400 Subject: [PATCH] Persist static_tab name. STUD-663. --- .../xmodule/modulestore/tests/test_mongo.py | 25 +++++++++++++++++++ common/lib/xmodule/xmodule/modulestore/xml.py | 1 + 2 files changed, 26 insertions(+) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py index 58c48f673e..17036a16bf 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py @@ -120,8 +120,30 @@ class TestMongoModuleStore(object): '{0} is a template course'.format(course) ) + def test_static_tab_names(self): + courses = self.store.get_courses() + + def get_tab_name(index): + """ + Helper function for pulling out the name of a given static tab. + + Assumes the information is desired for courses[1] ('toy' course). + """ + return courses[1].tabs[index]['name'] + + # There was a bug where model.save was not getting called after the static tab name + # was set set for tabs that have a URL slug. 'Syllabus' and 'Resources' fall into that + # category, but for completeness, I'm also testing 'Course Info' and 'Discussion' (no url slug). + assert_equals('Course Info', get_tab_name(1)) + assert_equals('Syllabus', get_tab_name(2)) + assert_equals('Resources', get_tab_name(3)) + assert_equals('Discussion', get_tab_name(4)) + class TestMongoKeyValueStore(object): + """ + Tests for MongoKeyValueStore. + """ def setUp(self): self.data = {'foo': 'foo_value'} @@ -131,6 +153,9 @@ class TestMongoKeyValueStore(object): self.kvs = MongoKeyValueStore(self.data, self.children, self.metadata, self.location, 'category') def _check_read(self, key, expected_value): + """ + Asserts the get and has methods. + """ assert_equals(expected_value, self.kvs.get(key)) assert self.kvs.has(key) diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py index 89c3299394..4c2011a3e5 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml.py +++ b/common/lib/xmodule/xmodule/modulestore/xml.py @@ -479,6 +479,7 @@ class XMLModuleStore(ModuleStoreBase): if tab.get('url_slug') == slug: module.display_name = tab['name'] module.data_dir = course_dir + module.save() self.modules[course_descriptor.id][module.location] = module except Exception, e: logging.exception("Failed to load {0}. Skipping... Exception: {1}".format(filepath, str(e)))