From 855c8bb7e7c7f9a6f1258d3e13e0f7a1cc6d8037 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Tue, 29 Jan 2013 13:44:42 -0500 Subject: [PATCH] add unit test for tab reordering --- cms/djangoapps/contentstore/tests/tests.py | 28 +++++++++++++++++++ cms/djangoapps/contentstore/views.py | 1 - .../data/full/policies/6.002_Spring_2012.json | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/tests/tests.py b/cms/djangoapps/contentstore/tests/tests.py index 3025ee78a4..bfdcfe1438 100644 --- a/cms/djangoapps/contentstore/tests/tests.py +++ b/cms/djangoapps/contentstore/tests/tests.py @@ -350,6 +350,34 @@ class ContentStoreTest(TestCase): def test_edit_unit_full(self): self.check_edit_unit('full') + def test_static_tab_reordering(self): + import_from_xml(modulestore(), 'common/test/data/', ['full']) + + # reverse the ordering + tabs = { 'tabs' : ['i4x://edX/full/static_tab/resources', 'i4x://edX/full/static_tab/syllabus'] } + resp = self.client.post(reverse('reorder_tabs'), json.dumps(tabs), "application/json") + + ms = modulestore('direct') + course = ms.get_item(Location(['i4x','edX','full','course','6.002_Spring_2012', None])) + # compare to make sure that the tabs information is in the expected order after the server call + + resource_idx = 0 + syllabus_idx = 0 + idx = 0 + for tab in course.tabs: + if tab['type'] == 'static_tab': + if tab['url_slug'] == 'resources': + resource_idx = idx + elif tab['url_slug'] == 'syllabus': + syllabus_idx = idx + idx+=1 + + self.assertLess(resource_idx, syllabus_idx) + + + + + def test_about_overrides(self): ''' This test case verifies that a course can use specialized override for about data, e.g. /about/Fall_2012/effort.html diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 326b47ee64..205bf787fd 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -908,7 +908,6 @@ def edit_static(request, org, course, coursename): @expect_json def reorder_tabs(request): tabs = request.POST['tabs'] - logging.debug('tabs = {0} {1}'.format(tabs.__class__, tabs)) if len(tabs) > 0: course = get_course_for_item(tabs[0]) diff --git a/common/test/data/full/policies/6.002_Spring_2012.json b/common/test/data/full/policies/6.002_Spring_2012.json index 345309ff5c..2f55528b7b 100644 --- a/common/test/data/full/policies/6.002_Spring_2012.json +++ b/common/test/data/full/policies/6.002_Spring_2012.json @@ -8,6 +8,7 @@ {"type": "courseware"}, {"type": "course_info", "name": "Course Info"}, {"type": "static_tab", "url_slug": "syllabus", "name": "Syllabus"}, + {"type": "static_tab", "url_slug": "resources", "name": "Resources"}, {"type": "discussion", "name": "Discussion"}, {"type": "wiki", "name": "Wiki"}, {"type": "progress", "name": "Progress"}