Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Etienne committed Jan 26, 2015
1 parent 96176bb commit 37a2026
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion user_management/api/tests/test_throttling.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ def test_post_rate_limit(self):
class TestResendConfirmationEmail(APIRequestTestCase):
view_class = views.ResendConfirmationEmail

@patch(THROTTLE_RATE_PATH, new={'confirmations': '0/minute'})
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."""
user = UserFactory.create()
Expand All @@ -110,5 +114,8 @@ def test_post_rate_limit(self):
request = self.create_request('post', data=data, auth=False)
view = self.view_class.as_view()

response = view(request)
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)

response = view(request)
self.assertEqual(response.status_code, status.HTTP_429_TOO_MANY_REQUESTS)

0 comments on commit 37a2026

Please sign in to comment.