diff --git a/src/apps/core/views.py b/src/apps/core/views.py index efcf519..f1bd6da 100644 --- a/src/apps/core/views.py +++ b/src/apps/core/views.py @@ -151,6 +151,7 @@ class ReadinessView(APIView): permission_classes = [AllowAny] authentication_classes = [] + throttle_classes = [] @swagger_auto_schema( tags=[HEALTH_TAG], diff --git a/tests/apps/core/test_views.py b/tests/apps/core/test_views.py index cbf2400..b191292 100644 --- a/tests/apps/core/test_views.py +++ b/tests/apps/core/test_views.py @@ -1,8 +1,19 @@ """Tests for core views (health checks)""" +from unittest.mock import patch + from django.urls import reverse from rest_framework import status from rest_framework.test import APITestCase +from rest_framework.throttling import BaseThrottle +from rest_framework.views import APIView + + +class RejectAllThrottle(BaseThrottle): + """Test throttle proving readiness ignores inherited API throttles.""" + + def allow_request(self, request, view): + return False class HealthCheckViewTest(APITestCase): @@ -66,6 +77,16 @@ class ReadinessViewTest(APITestCase): self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data["status"], "ready") + def test_readiness_bypasses_inherited_api_throttles(self): + """Readiness probes remain available when global throttles reject traffic.""" + url = reverse("core:readiness") + + with patch.object(APIView, "throttle_classes", [RejectAllThrottle]): + response = self.client.get(url) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual(response.data["status"], "ready") + class APIVersioningURLTest(APITestCase): """Tests for API versioning URL structure"""