Exemple #1
0
 def test_form_valid_anonymous(self, form_valid_mock):
     Verify = BrowserIDVerify()
     request_mock = Mock()
     request_mock.user.is_authenticated.return_value = False
     Verify.request = request_mock
     form = Mock()
     Verify.form_valid(form)
     form_valid_mock.assert_called_with(form)
Exemple #2
0
 def test_form_valid_anonymous(self, form_valid_mock):
     Verify = BrowserIDVerify()
     request_mock = Mock()
     request_mock.user.is_authenticated.return_value = False
     Verify.request = request_mock
     form = Mock()
     Verify.form_valid(form)
     form_valid_mock.assert_called_with(form)
Exemple #3
0
    def test_form_valid_authenticated(self, verify_mock, get_audience_mock):
        user = UserFactory.create()
        Verify = BrowserIDVerify()
        request_mock = Mock()
        request_mock.user.is_authenticated.return_value = True
        request_mock.user = user
        Verify.request = request_mock
        form = Mock()
        form.cleaned_data = {'assertion': 'assertion'}
        get_audience_mock.return_value = 'audience'
        verify_mock.return_value = {'email': '*****@*****.**'}

        Verify.form_valid(form)

        verify_mock.assert_called_with('assertion', 'audience')
        get_audience_mock.assert_called_with(request_mock)
        eq_(user.email, '*****@*****.**')
Exemple #4
0
    def test_form_valid_authenticated(self, verify_mock, get_audience_mock):
        user = UserFactory.create()
        Verify = BrowserIDVerify()
        request_mock = Mock()
        request_mock.user.is_authenticated.return_value = True
        request_mock.user = user
        Verify.request = request_mock
        form = Mock()
        form.cleaned_data = {'assertion': 'assertion'}
        get_audience_mock.return_value = 'audience'
        verify_mock.return_value = {'email': '*****@*****.**'}

        Verify.form_valid(form)

        verify_mock.assert_called_with('assertion', 'audience')
        get_audience_mock.assert_called_with(request_mock)
        eq_(user.email, '*****@*****.**')