From 72a0d195314490a7f4b1cef7a1f58a7d79b934c9 Mon Sep 17 00:00:00 2001 From: Diana Huang Date: Tue, 16 Jun 2015 15:46:23 -0400 Subject: [PATCH] Ensure that is_hidden does not affect equality checks. --- .../contentstore/tests/test_course_settings.py | 18 ++++++++++++++++++ common/lib/xmodule/xmodule/tabs.py | 4 +--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/test_course_settings.py b/cms/djangoapps/contentstore/tests/test_course_settings.py index 1450f37df4..2ecb83f802 100644 --- a/cms/djangoapps/contentstore/tests/test_course_settings.py +++ b/cms/djangoapps/contentstore/tests/test_course_settings.py @@ -973,6 +973,24 @@ class CourseMetadataEditingTest(CourseTestCase): self.assertNotIn(peer_grading_tab, course.tabs) self.assertNotIn(notes_tab, course.tabs) + def mark_wiki_as_hidden(self, tabs): + """ Mark the wiki tab as hidden. """ + for tab in tabs: + if tab.type == 'wiki': + tab['is_hidden'] = True + return tabs + + def test_advanced_components_munge_tabs_hidden_tabs(self): + updated_tabs = self.mark_wiki_as_hidden(self.course.tabs) + self.course.tabs = updated_tabs + modulestore().update_item(self.course, self.user.id) + self.client.ajax_post(self.course_setting_url, { + ADVANCED_COMPONENT_POLICY_KEY: {"value": ["notes"]} + }) + course = modulestore().get_course(self.course.id) + notes_tab = {"type": "notes", "name": "My Notes"} + self.assertIn(notes_tab, course.tabs) + class CourseGraderUpdatesTest(CourseTestCase): """ diff --git a/common/lib/xmodule/xmodule/tabs.py b/common/lib/xmodule/xmodule/tabs.py index f7e861539b..9a713ac046 100644 --- a/common/lib/xmodule/xmodule/tabs.py +++ b/common/lib/xmodule/xmodule/tabs.py @@ -138,10 +138,8 @@ class CourseTab(object): # allow tabs without names; if a name is required, its presence was checked in the validator. name_is_eq = (other.get('name') is None or self.name == other['name']) - is_hidden_eq = self.is_hidden == other.get('is_hidden', False) - # only compare the persisted/serialized members: 'type' and 'name' - return self.type == other.get('type') and name_is_eq and is_hidden_eq + return self.type == other.get('type') and name_is_eq def __ne__(self, other): """