From 39a32744dfc444dc5ceac1ed396d47d9ff33d9f1 Mon Sep 17 00:00:00 2001 From: 0x29a Date: Tue, 14 Nov 2023 16:53:55 +0100 Subject: [PATCH] test: cover the new endpoing with tests --- enterprise/api/v1/views.py | 4 ++-- enterprise/settings/test.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/enterprise/api/v1/views.py b/enterprise/api/v1/views.py index bb7793f20a..77389caf2f 100644 --- a/enterprise/api/v1/views.py +++ b/enterprise/api/v1/views.py @@ -534,7 +534,7 @@ def algolia_key(self, request, *args, **kwargs): """ if not settings.ENTERPRISE_ALGOLIA_SEARCH_API_KEY: - raise ValidationError("Algolia API key not configured.", code=HTTP_500_INTERNAL_SERVER_ERROR) + return Response("Algolia API key not configured", status=status.HTTP_500_INTERNAL_SERVER_ERROR) queryset = self.queryset.filter( **{ @@ -544,7 +544,7 @@ def algolia_key(self, request, *args, **kwargs): ).values_list("uuid", flat=True) if len(queryset) == 0: - raise ValidationError("User is not linked to any enterprise customers.", code=HTTP_404_NOT_FOUND) + raise NotFound("User is not linked to any enterprise customers.") secured_key = SearchClient.generate_secured_api_key( settings.ENTERPRISE_ALGOLIA_SEARCH_API_KEY, diff --git a/enterprise/settings/test.py b/enterprise/settings/test.py index 9a53f10e0d..50fd95e46e 100644 --- a/enterprise/settings/test.py +++ b/enterprise/settings/test.py @@ -219,6 +219,8 @@ def root(*args): 'status': 'published' } +ENTERPRISE_ALGOLIA_SEARCH_API_KEY = 'test' + SNOWFLAKE_SERVICE_USER = 'TEST@EDX.ORG' SNOWFLAKE_SERVICE_USER_PASSWORD = 'secret'