def test_banned(self, message_mock, auth_mock):
        self.user.is_active = False
        auth_mock.return_value = self.user
        response = auth_view(self.request)

        self.assertEqual(response.status_code, 302)
        message_mock.assert_called_with(self.request, 'Your account has been banned,' \
                                        ' please contact us to re-activate your account!')
示例#2
0
    def test_banned(self, message_mock, auth_mock):
        self.user.is_active = False
        auth_mock.return_value = self.user
        response = auth_view(self.request)

        self.assertEqual(response.status_code, 302)
        message_mock.assert_called_with(self.request, 'Your account has been banned,' \
                                        ' please contact us to re-activate your account!')
    def test_sucess_logged_in(self, login_mock, message_mock, auth_mock):
        self.user.is_active = True
        self.user.last_name = 'testlname'
        auth_mock.return_value = self.user
        response = auth_view(self.request)

        self.assertEqual(response.status_code, 302)
        auth_mock.assert_called_with(username='******', password='******')
        login_mock.assert_called_with(self.request, self.user)
        message_mock.assert_called_with(self.request,
                                        'Hi testlname, you have successfully logged in.')
示例#4
0
    def test_sucess_logged_in(self, login_mock, message_mock, auth_mock):
        self.user.is_active = True
        self.user.last_name = 'testlname'
        auth_mock.return_value = self.user
        response = auth_view(self.request)

        self.assertEqual(response.status_code, 302)
        auth_mock.assert_called_with(username='******', password='******')
        login_mock.assert_called_with(self.request, self.user)
        message_mock.assert_called_with(
            self.request, 'Hi testlname, you have successfully logged in.')
 def test_failed_logged_in(self, message_mock, auth_mock):
     auth_mock.return_value = None
     response = auth_view(self.request)
     self.assertEqual(response.status_code, 302)
     message_mock.assert_called_with(self.request, 'The account you entered' \
                                     ' is invalid, please try again!')
示例#6
0
 def test_failed_logged_in(self, message_mock, auth_mock):
     auth_mock.return_value = None
     response = auth_view(self.request)
     self.assertEqual(response.status_code, 302)
     message_mock.assert_called_with(self.request, 'The account you entered' \
                                     ' is invalid, please try again!')