Total Complexity | 5 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | from django.contrib.auth import user_logged_out |
||
11 | class TokenDestroyViewTest(restframework.APIViewTestCase, |
||
12 | assertions.StatusCodeAssertionsMixin): |
||
13 | view_class = djoser.views.TokenDestroyView |
||
14 | |||
15 | def setUp(self): |
||
16 | self.signal_sent = False |
||
17 | |||
18 | def signal_receiver(self, *args, **kwargs): |
||
19 | self.signal_sent = True |
||
20 | |||
21 | def test_post_should_logout_logged_in_user(self): |
||
22 | user = create_user() |
||
23 | user_logged_out.connect(self.signal_receiver) |
||
24 | request = self.factory.post(user=user) |
||
25 | |||
26 | response = self.view(request) |
||
27 | |||
28 | self.assert_status_equal(response, status.HTTP_204_NO_CONTENT) |
||
29 | self.assertEqual(response.data, None) |
||
30 | self.assertTrue(self.signal_sent) |
||
31 | |||
32 | def test_post_should_deny_logging_out_when_user_not_logged_in(self): |
||
33 | create_user() |
||
34 | request = self.factory.post() |
||
35 | |||
36 | response = self.view(request) |
||
37 | |||
38 | self.assert_status_equal(response, status.HTTP_401_UNAUTHORIZED) |
||
39 | |||
40 | def test_options(self): |
||
41 | user = create_user() |
||
42 | request = self.factory.options(user=user) |
||
43 | |||
44 | response = self.view(request) |
||
45 | |||
46 | self.assert_status_equal(response, status.HTTP_200_OK) |
||
47 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.