aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tests/throttling.py
diff options
context:
space:
mode:
authorTom Christie2012-09-13 18:32:56 +0100
committerTom Christie2012-09-13 18:32:56 +0100
commit6c109ac60f891955df367c61d4d7094039098076 (patch)
tree813962df0083994aa70e9e5c3f81f8bc677a583b /djangorestframework/tests/throttling.py
parentb16c45aa6dfb5937d01f0c89273cd24f5e729f60 (diff)
downloaddjango-rest-framework-6c109ac60f891955df367c61d4d7094039098076.tar.bz2
Improve throttles and docs
Diffstat (limited to 'djangorestframework/tests/throttling.py')
-rw-r--r--djangorestframework/tests/throttling.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/djangorestframework/tests/throttling.py b/djangorestframework/tests/throttling.py
index d144d956..9ee4ffa4 100644
--- a/djangorestframework/tests/throttling.py
+++ b/djangorestframework/tests/throttling.py
@@ -8,24 +8,30 @@ from django.core.cache import cache
from djangorestframework.compat import RequestFactory
from djangorestframework.views import APIView
-from djangorestframework.throttling import PerUserThrottling, PerViewThrottling
+from djangorestframework.throttling import UserRateThrottle
from djangorestframework.response import Response
-class MockView(APIView):
- throttle_classes = (PerUserThrottling,)
+class User3SecRateThrottle(UserRateThrottle):
rate = '3/sec'
+
+class User3MinRateThrottle(UserRateThrottle):
+ rate = '3/min'
+
+
+class MockView(APIView):
+ throttle_classes = (User3SecRateThrottle,)
+
def get(self, request):
return Response('foo')
-class MockView_PerViewThrottling(MockView):
- throttle_classes = (PerViewThrottling,)
+class MockView_MinuteThrottling(APIView):
+ throttle_classes = (User3MinRateThrottle,)
-
-class MockView_MinuteThrottling(MockView):
- rate = '3/min'
+ def get(self, request):
+ return Response('foo')
class ThrottlingTests(TestCase):
@@ -86,12 +92,6 @@ class ThrottlingTests(TestCase):
"""
self.ensure_is_throttled(MockView, 200)
- def test_request_throttling_is_per_view(self):
- """
- Ensure request rate is limited globally per View for PerViewThrottles
- """
- self.ensure_is_throttled(MockView_PerViewThrottling, 429)
-
def ensure_response_header_contains_proper_throttle_field(self, view, expected_headers):
"""
Ensure the response returns an X-Throttle field with status and next attributes