示例#1
0
    def test_post_authenticated_signal(self):
        self.called = []

        def signal_handler(sender, instance, session_info, request, **kwargs):
            self.called.append({
                'sender': sender,
                'instance': instance,
                'request': request,
                'session_info': session_info
            })

        post_authenticated.connect(signal_handler, dispatch_uid='test_signal')

        self.do_login()

        # make sure the handler is only called once
        self.assertEqual(len(self.called), 1)
        # test 'sender', this should be User.__class__
        self.assertEqual(self.called[0]['sender'], get_user_model(),
                         'post_authenticated signal sender is not a User')
        # test 'instance', this should be User
        self.assertIsInstance(
            self.called[0]['instance'], get_user_model(),
            'post_authenticated signal did not send a User instance')
        # test the request
        self.assertIsInstance(
            self.called[0]['request'], HttpRequest,
            'post_authenticated signal did not send a request')
        # test the session_info
        self.assertIsInstance(
            self.called[0]['session_info'], dict,
            'post_authenticated signal did not send a session_info dict')

        post_authenticated.disconnect(dispatch_uid='test_signal')
示例#2
0
    def test_post_authenticated_signal(self):
        def signal_handler(signal, user, session_info):
            self.assertEquals(isinstance(user, User), True)

        post_authenticated.connect(signal_handler, dispatch_uid='test_signal')

        self.do_login()

        post_authenticated.disconnect(dispatch_uid='test_signal')
示例#3
0
    def test_post_authenticated_signal(self):

        def signal_handler(signal, user, session_info):
            self.assertEquals(isinstance(user, User), True)

        post_authenticated.connect(signal_handler, dispatch_uid='test_signal')

        self.do_login()

        post_authenticated.disconnect(dispatch_uid='test_signal')