fix: keep readiness probes unthrottled
All checks were successful
State Corp Backend CI/CD / Quality gate (push) Successful in 9m25s
State Corp Backend CI/CD / Build linux/amd64 images once (push) Successful in 4m34s
State Corp Backend CI/CD / Release dev (push) Successful in 1m2s
State Corp Backend CI/CD / Refresh and release internal main (push) Has been skipped
State Corp Backend CI/CD / Release customer main (push) Has been skipped

This commit is contained in:
2026-08-27 15:00:23 +03:00
parent b2a45aef51
commit ef087d5559
2 changed files with 22 additions and 0 deletions

View File

@@ -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"""