From 974c0a94b393a57cc299c120b8fbd9769cd064c2 Mon Sep 17 00:00:00 2001 From: Matt Lenc Date: Fri, 31 Oct 2014 15:22:27 +0000 Subject: [PATCH] Patch class as shared variable --- user_management/api/tests/test_views.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/user_management/api/tests/test_views.py b/user_management/api/tests/test_views.py index 45ddd2d..318cd33 100644 --- a/user_management/api/tests/test_views.py +++ b/user_management/api/tests/test_views.py @@ -21,6 +21,7 @@ User = get_user_model() TEST_SERVER = 'http://testserver' +THROTTLE_RATE_PATH = 'rest_framework.throttling.ScopedRateThrottle.THROTTLE_RATES' class GetTokenTest(APIRequestTestCase): @@ -87,9 +88,7 @@ def test_user_auth_throttle_GET_requests(self): self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) - @patch('rest_framework.throttling.ScopedRateThrottle.THROTTLE_RATES', new={ - 'logins': '1/minute', - }) + @patch(THROTTLE_RATE_PATH, new={'logins': '1/minute'}) def test_user_auth_throttle_POST_requests(self): """Ensure POST requests are throttled correctly.""" data = { @@ -231,9 +230,7 @@ def test_existent_email(self): send_email.assert_called_once_with(user) - @patch('rest_framework.throttling.ScopedRateThrottle.THROTTLE_RATES', new={ - 'passwords': '1/minute', - }) + @patch(THROTTLE_RATE_PATH, new={'passwords': '1/minute'}) def test_post_rate_limit(self): """Ensure the POST requests are rate limited.""" email = 'exists@example.com'