'Test re-ordering of tabs'

def test_reorder_tabs(self):

    orig_tab_ids = [tab.tab_id for tab in self.course.tabs]
    tab_ids = list(orig_tab_ids)
    num_orig_tabs = len(orig_tab_ids)
    self.assertGreaterEqual(num_orig_tabs, 5)
    (tab_ids[(num_orig_tabs - 1)], tab_ids[(num_orig_tabs - 2)]) = (tab_ids[(num_orig_tabs - 2)], tab_ids[(num_orig_tabs - 1)])
    removed_tab = tab_ids.pop((num_orig_tabs / 2))
    self.assertEqual(len(tab_ids), (num_orig_tabs - 1))
    resp = self.client.ajax_post(self.url, data={'tabs': [{'tab_id': tab_id} for tab_id in tab_ids]})
    self.assertEqual(resp.status_code, 204)
    self.reload_course()
    new_tab_ids = [tab.tab_id for tab in self.course.tabs]
    self.assertEqual(new_tab_ids, (tab_ids + [removed_tab]))
    self.assertNotEqual(new_tab_ids, orig_tab_ids)
