don't hard code the ordering of the tabs in the test. Take the current ordering defintion (in the test data) and reverse it

This commit is contained in:
Chris Dodge
2013-01-30 09:43:57 -05:00
parent 855c8bb7e7
commit 74fcf96611

View File

@@ -353,27 +353,26 @@ class ContentStoreTest(TestCase):
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]))
# reverse the ordering
reverse_tabs = []
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")
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
course_tabs = []
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)
course_tabs.append('i4x://edX/full/static_tab/{0}'.format(tab['url_slug']))
self.assertEqual(reverse_tabs, course_tabs)