Skip to content

Commit

Permalink
Moar real tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Lenc committed May 30, 2014
1 parent c4c3157 commit b763471
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions user_management/api/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,31 @@ class TestThrottle(APIRequestTestCase):
})
def test_user_auth_throttle(self):
auth_url = reverse('user_management_api:auth')
expected_status = status.HTTP_429_TOO_MANY_REQUESTS

request = APIRequestFactory().get(auth_url)
for x in range(2):
response = self.view_class.as_view()(request)
self.assertEqual(response.status_code, status.HTTP_429_TOO_MANY_REQUESTS)

response = self.view_class.as_view()(request)
self.assertNotEqual(response.status_code, expected_status)

response = self.view_class.as_view()(request)
self.assertEqual(response.status_code, expected_status)

@patch('rest_framework.throttling.SimpleRateThrottle.THROTTLE_RATES', new={
'anon': '1/day',
'user': '1/day',
'anon': '2/day',
'user': '2/day',

This comment has been minimized.

Copy link
@LilyFoote

LilyFoote May 31, 2014

Contributor

Why did this need to change?

This comment has been minimized.

Copy link
@mlen108

mlen108 Jun 2, 2014

Contributor

I was testing same class so all requests were counted in . Fixed now in 1a448ae

})
def test_user_password_reset_throttle(self):
auth_url = reverse('user_management_api:password_reset')
expected_status = status.HTTP_429_TOO_MANY_REQUESTS

request = APIRequestFactory().get(auth_url)
for x in range(2):
response = self.view_class.as_view()(request)
self.assertEqual(response.status_code, status.HTTP_429_TOO_MANY_REQUESTS)

response = self.view_class.as_view()(request)
self.assertNotEqual(response.status_code, expected_status)

response = self.view_class.as_view()(request)
self.assertEqual(response.status_code, expected_status)


class GetTokenTest(APIRequestTestCase):
Expand Down

0 comments on commit b763471

Please sign in to comment.