'Tests the API to get a paginated list of CCX Courses'

@ddt.data(*AUTH_ATTRS)
def test_get_paginated_list(self, auth_attr):

    num_ccx = 357
    for _ in xrange(num_ccx):
        self.make_ccx()
    page_size = settings.REST_FRAMEWORK.get('PAGE_SIZE', 10)
    num_pages = int(math.ceil((num_ccx / float(page_size))))
    resp = self.client.get(self.list_url_master_course, {}, HTTP_AUTHORIZATION=getattr(self, auth_attr))
    self.assertEqual(resp.status_code, status.HTTP_200_OK)
    self.assertEqual(resp.data['count'], num_ccx)
    self.assertEqual(resp.data['num_pages'], num_pages)
    self.assertEqual(resp.data['current_page'], 1)
    self.assertEqual(resp.data['start'], 0)
    self.assertIsNotNone(resp.data['next'])
    self.assertIsNone(resp.data['previous'])
    url = '{0}&page=24'.format(self.list_url_master_course)
    resp = self.client.get(url, {}, HTTP_AUTHORIZATION=getattr(self, auth_attr))
    self.assertEqual(resp.status_code, status.HTTP_200_OK)
    self.assertEqual(resp.data['count'], num_ccx)
    self.assertEqual(resp.data['num_pages'], num_pages)
    self.assertEqual(resp.data['current_page'], 24)
    self.assertEqual(resp.data['start'], ((resp.data['current_page'] - 1) * page_size))
    self.assertIsNotNone(resp.data['next'])
    self.assertIsNotNone(resp.data['previous'])
    url = '{0}&page={1}'.format(self.list_url_master_course, num_pages)
    resp = self.client.get(url, {}, HTTP_AUTHORIZATION=getattr(self, auth_attr))
    self.assertEqual(resp.status_code, status.HTTP_200_OK)
    self.assertEqual(resp.data['count'], num_ccx)
    self.assertEqual(resp.data['num_pages'], num_pages)
    self.assertEqual(resp.data['current_page'], num_pages)
    self.assertEqual(resp.data['start'], ((resp.data['current_page'] - 1) * page_size))
    self.assertIsNone(resp.data['next'])
    self.assertIsNotNone(resp.data['previous'])
    url = '{0}&page={1}'.format(self.list_url_master_course, (num_pages + 1))
    resp = self.client.get(url, {}, HTTP_AUTHORIZATION=getattr(self, auth_attr))
    self.assertEqual(resp.status_code, status.HTTP_404_NOT_FOUND)
