From d5a63b6e31c59ce6c36eb459d2ed2bfe96fe1749 Mon Sep 17 00:00:00 2001 From: Kevin Etienne Date: Mon, 26 Jan 2015 17:24:02 +0000 Subject: [PATCH] Fix typos --- user_management/api/serializers.py | 4 ++-- user_management/api/tests/test_throttling.py | 24 ++++++++------------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/user_management/api/serializers.py b/user_management/api/serializers.py index b7f3f25..2d159c9 100644 --- a/user_management/api/serializers.py +++ b/user_management/api/serializers.py @@ -175,11 +175,11 @@ def validate_email(self, attrs, source): try: self.user = User.objects.get_by_natural_key(email) except User.DoesNotExist: - msg = _('User does not exists.') + msg = _('A user with this email address does not exist.') raise serializers.ValidationError(msg) if not self.user.email_verification_required: - msg = _('User is already confirmed.') + msg = _('User email address is already verified.') raise serializers.ValidationError(msg) return attrs diff --git a/user_management/api/tests/test_throttling.py b/user_management/api/tests/test_throttling.py index 88e43c8..dbdc608 100644 --- a/user_management/api/tests/test_throttling.py +++ b/user_management/api/tests/test_throttling.py @@ -11,17 +11,19 @@ THROTTLE_RATE_PATH = 'rest_framework.throttling.ScopedRateThrottle.THROTTLE_RATES' -class GetAuthTokenTest(APIRequestTestCase): +class ClearCacheMixin: + def tearDown(self): + # DRF puts a successful (not throttled) request into a cache + cache.clear() + + +class GetAuthTokenTest(ClearCacheMixin, APIRequestTestCase): throttle_expected_status = status.HTTP_429_TOO_MANY_REQUESTS view_class = views.GetAuthToken def setUp(self): self.auth_url = reverse('user_management_api:auth') - def tearDown(self): - # DRF puts a successful (not throttled) request onto a cache - cache.clear() - @patch(THROTTLE_RATE_PATH, new={'logins': '1/minute'}) def test_user_auth_throttle(self): """Ensure POST requests are throttled correctly.""" @@ -73,13 +75,9 @@ def test_user_auth_throttle_username(self): self.assertEqual(response.status_code, self.throttle_expected_status) -class TestPasswordResetEmail(APIRequestTestCase): +class TestPasswordResetEmail(ClearCacheMixin, APIRequestTestCase): view_class = views.PasswordResetEmail - def tearDown(self): - # DRF puts a successful (not throttled) request onto a cache - cache.clear() - @patch(THROTTLE_RATE_PATH, new={'passwords': '1/minute'}) def test_post_rate_limit(self): """Ensure the POST requests are rate limited.""" @@ -98,13 +96,9 @@ def test_post_rate_limit(self): self.assertEqual(response.status_code, status.HTTP_429_TOO_MANY_REQUESTS) -class TestResendConfirmationEmail(APIRequestTestCase): +class TestResendConfirmationEmail(ClearCacheMixin, APIRequestTestCase): view_class = views.ResendConfirmationEmail - def tearDown(self): - # DRF puts a successful (not throttled) request onto a cache - cache.clear() - @patch(THROTTLE_RATE_PATH, new={'confirmations': '1/minute'}) def test_post_rate_limit(self): """Assert POST requests are rate limited."""