'Verify that paginated data can be retrieved.'

@waffle.testutils.override_switch('populate-multitenant-programs', True)
def test_get_paginated_data(self):

    catalog_integration = self.create_catalog_integration()
    api = create_catalog_api_client(self.user)
    expected_collection = ['some', 'test', 'data']
    url = (CatalogIntegration.current().get_internal_api_url().strip('/') + '/programs/?page={}')
    responses = []
    for (page, record) in enumerate(expected_collection, start=1):
        data = {'next': (url.format((page + 1)) if (page < len(expected_collection)) else None), 'results': [record]}
        body = json.dumps(data)
        responses.append(httpretty.Response(body=body, content_type='application/json'))
    self._mock_catalog_api(responses)
    actual_collection = get_edx_api_data(catalog_integration, 'programs', api=api)
    self.assertEqual(actual_collection, expected_collection)
    self._assert_num_requests(len(expected_collection))
