'Mock the Course Catalog API\'s catalog endpoint.'

def mock_catalog_endpoint(self, data, catalog_id=None, method=httpretty.GET, status_code=200):

    self.assertTrue(httpretty.is_enabled(), msg='httpretty    must    be    enabled    to    mock    Catalog    API    calls.')
    url = '{root}/catalogs/'.format(root=settings.COURSE_CATALOG_API_URL.rstrip('/'))
    if catalog_id:
        url += '{id}/'.format(id=catalog_id)
    httpretty.register_uri(method, url, body=json.dumps(data), content_type='application/json', status=status_code)
