diff options
| author | Tom Christie | 2015-02-09 20:43:50 +0000 |
|---|---|---|
| committer | Tom Christie | 2015-02-09 20:43:50 +0000 |
| commit | fbb21caaaa01033bbd34b0c63ab48243ffb6310e (patch) | |
| tree | 5d0fdee18c9bf02733b1df913c4cddd9e3e86da7 /tests/test_authentication.py | |
| parent | 407480b4840990ff17f9a33b293cfcf15bb6f7c5 (diff) | |
| parent | 7b639c0cd0676172cc8502e833f5b708f39f9a83 (diff) | |
| download | django-rest-framework-fbb21caaaa01033bbd34b0c63ab48243ffb6310e.tar.bz2 | |
Merge master
Diffstat (limited to 'tests/test_authentication.py')
| -rw-r--r-- | tests/test_authentication.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/test_authentication.py b/tests/test_authentication.py index 04c5782e..91e49f9d 100644 --- a/tests/test_authentication.py +++ b/tests/test_authentication.py @@ -168,6 +168,15 @@ class TokenAuthTests(TestCase): response = self.csrf_client.post('/token/', {'example': 'example'}, format='json', HTTP_AUTHORIZATION=auth) self.assertEqual(response.status_code, status.HTTP_200_OK) + def test_post_json_makes_one_db_query(self): + """Ensure that authenticating a user using a token performs only one DB query""" + auth = "Token " + self.key + + def func_to_test(): + return self.csrf_client.post('/token/', {'example': 'example'}, format='json', HTTP_AUTHORIZATION=auth) + + self.assertNumQueries(1, func_to_test) + def test_post_form_failing_token_auth(self): """Ensure POSTing form over token auth without correct credentials fails""" response = self.csrf_client.post('/token/', {'example': 'example'}) |
