def test_invalid(self): request = self.factory.post('', { 'login': self.user.username, 'password': '******', }) self.add_session_to_request(request) response = login(request) self.assert_invalid_response(response, status.HTTP_400_BAD_REQUEST)
def test_success(self): request = self.factory.post('', { 'login': self.user.username, 'password': self.password, }) self.add_session_to_request(request) response = login(request) self.assert_valid_response(response, status.HTTP_200_OK)
def test_success_with_token(self): request = self.factory.post('', { 'login': self.user.username, 'password': self.password, }) self.add_session_to_request(request) response = login(request) self.assert_valid_response(response, status.HTTP_200_OK) self.assertIn('token', response.data) token_key = response.data['token'] token = Token.objects.get(key=token_key) self.assertEqual(token.user, self.user)