Commit 74fcf966 by Chris Dodge

don't hard code the ordering of the tabs in the test. Take the current ordering…

don't hard code the ordering of the tabs in the test. Take the current ordering defintion (in the test data) and reverse it
parent 855c8bb7
...@@ -353,27 +353,26 @@ class ContentStoreTest(TestCase): ...@@ -353,27 +353,26 @@ class ContentStoreTest(TestCase):
def test_static_tab_reordering(self): def test_static_tab_reordering(self):
import_from_xml(modulestore(), 'common/test/data/', ['full']) import_from_xml(modulestore(), 'common/test/data/', ['full'])
ms = modulestore('direct')
course = ms.get_item(Location(['i4x','edX','full','course','6.002_Spring_2012', None]))
# reverse the ordering # reverse the ordering
tabs = { 'tabs' : ['i4x://edX/full/static_tab/resources', 'i4x://edX/full/static_tab/syllabus'] } reverse_tabs = []
resp = self.client.post(reverse('reorder_tabs'), json.dumps(tabs), "application/json") for tab in course.tabs:
if tab['type'] == 'static_tab':
reverse_tabs.insert(0, 'i4x://edX/full/static_tab/{0}'.format(tab['url_slug']))
resp = self.client.post(reverse('reorder_tabs'), json.dumps({'tabs':reverse_tabs}), "application/json")
ms = modulestore('direct')
course = ms.get_item(Location(['i4x','edX','full','course','6.002_Spring_2012', None])) 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 # compare to make sure that the tabs information is in the expected order after the server call
resource_idx = 0 course_tabs = []
syllabus_idx = 0
idx = 0
for tab in course.tabs: for tab in course.tabs:
if tab['type'] == 'static_tab': if tab['type'] == 'static_tab':
if tab['url_slug'] == 'resources': course_tabs.append('i4x://edX/full/static_tab/{0}'.format(tab['url_slug']))
resource_idx = idx
elif tab['url_slug'] == 'syllabus':
syllabus_idx = idx
idx+=1
self.assertLess(resource_idx, syllabus_idx)
self.assertEqual(reverse_tabs, course_tabs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment