diff --git a/enterprise_subsidy/apps/api_client/enterprise_catalog.py b/enterprise_subsidy/apps/api_client/enterprise_catalog.py index b3abdb25..980a701d 100644 --- a/enterprise_subsidy/apps/api_client/enterprise_catalog.py +++ b/enterprise_subsidy/apps/api_client/enterprise_catalog.py @@ -44,7 +44,8 @@ def get_content_metadata(self, content_identifier, **kwargs): try: response = self.client.get(content_metadata_url, params=query_params) response.raise_for_status() - return response.json() + response_json = response.json() + return response_json['results'][0] if response_json['results'] else None except requests.exceptions.HTTPError as exc: if hasattr(response, 'text'): logger.exception( diff --git a/enterprise_subsidy/apps/api_client/tests/test_enterprise_catalog.py b/enterprise_subsidy/apps/api_client/tests/test_enterprise_catalog.py index 9337790d..23d5a9dd 100644 --- a/enterprise_subsidy/apps/api_client/tests/test_enterprise_catalog.py +++ b/enterprise_subsidy/apps/api_client/tests/test_enterprise_catalog.py @@ -101,7 +101,15 @@ def test_successful_fetch_course_content_metadata(self, mock_oauth_client): Test the enterprise catalog client's ability to handle api requests to fetch content metadata from the catalog service. """ - mock_oauth_client.return_value.get.return_value = MockResponse(self.course_metadata, 200) + mock_oauth_client.return_value.get.return_value = MockResponse( + { + 'results': [self.course_metadata], + 'count': 1, + 'next': None, + 'previous': None, + }, + 200, + ) enterprise_catalog_client = EnterpriseCatalogApiClient() response = enterprise_catalog_client.get_content_metadata(self.course_key) assert response == self.course_metadata