コード例 #1
0
ファイル: test_views.py プロジェクト: opentrv/janus
    def test_get_with_an_unauthenticated_user_renders_sign_in_sign_up_form(self, render, login, authenticate):
        request = mock.Mock()
        request.method = 'GET'
        request.user = mock.Mock()
        request.user.is_authenticated.return_value = False

        response = sign_in(request)

        render.assert_called_once_with(request, 'brent/sign-in.html')
コード例 #2
0
    def test_get_with_an_unauthenticated_user_renders_sign_in_sign_up_form(
            self, render, login, authenticate):
        request = mock.Mock()
        request.method = 'GET'
        request.user = mock.Mock()
        request.user.is_authenticated.return_value = False

        response = sign_in(request)

        render.assert_called_once_with(request, 'brent/sign-in.html')
コード例 #3
0
    def test_successful_authentication_logs_in_user(self, login, authenticate):
        request = mock.Mock()
        request.method = 'POST'
        request.POST = mock.Mock(__getitem__=mock.Mock())
        user = mock.Mock()
        authenticate.return_value = user

        response = sign_in(request)

        login.assert_called_once_with(request, user)
コード例 #4
0
ファイル: test_views.py プロジェクト: opentrv/janus
    def test_get_with_an_authenticated_user_without_permissions_redirects_to_user_permissions(self, redirect, login, authenticate):
        request = mock.Mock()
        request.method = 'GET'
        request.user = mock.Mock()
        request.user.is_authenticated.return_value = True
        request.user.has_perm.return_value = False

        response = sign_in(request)

        redirect.assert_called_once_with('/brent/user-permissions')
コード例 #5
0
ファイル: test_views.py プロジェクト: opentrv/janus
    def test_successful_authentication_logs_in_user(self, login, authenticate):
        request = mock.Mock()
        request.method = 'POST'
        request.POST = mock.Mock(__getitem__=mock.Mock())
        user = mock.Mock()
        authenticate.return_value = user

        response = sign_in(request)
        
        login.assert_called_once_with(request, user)
コード例 #6
0
    def test_get_with_an_authenticated_user_without_permissions_redirects_to_user_permissions(
            self, redirect, login, authenticate):
        request = mock.Mock()
        request.method = 'GET'
        request.user = mock.Mock()
        request.user.is_authenticated.return_value = True
        request.user.has_perm.return_value = False

        response = sign_in(request)

        redirect.assert_called_once_with('/brent/user-permissions')
コード例 #7
0
ファイル: test_views.py プロジェクト: opentrv/janus
    def test_get_with_an_authenticated_user_with_permissions_redirect_to_homepage(self, redirect, login, authenticate):
        request = mock.Mock()
        request.method = 'GET'
        request.user = mock.Mock()
        request.user.is_authenticated.return_value = True
        request.user.has_perm.return_value = True

        response = sign_in(request)

        request.user.has_perm.assert_called_once_with('opentrv_sensor.view_measurement')
        redirect.assert_called_once_with('/brent')
コード例 #8
0
    def test_get_with_an_authenticated_user_with_permissions_redirect_to_homepage(
            self, redirect, login, authenticate):
        request = mock.Mock()
        request.method = 'GET'
        request.user = mock.Mock()
        request.user.is_authenticated.return_value = True
        request.user.has_perm.return_value = True

        response = sign_in(request)

        request.user.has_perm.assert_called_once_with(
            'opentrv_sensor.view_measurement')
        redirect.assert_called_once_with('/brent')