Esempio n. 1
0
    def test_if_user_exists_already_raise_error(self, render, User):
        User.objects.filter.return_value = [mock.Mock()]
        request = mock.Mock()
        request.POST = {
            'email': '*****@*****.**',
            'password': '******',
            'password-confirmation': 'secret'
        }

        response = sign_up(request)

        render.assert_called_once_with(request, 'brent/sign-in.html', {'sign_up_email': '*****@*****.**', 'sign_up_errors': ['This email address is already registered']})
Esempio n. 2
0
    def test_raises_error_when_passwords_do_not_match(self, render, User):
        ''' it should raise an error when the password and password-confirmation do not match '''
        request = mock.Mock()
        request.POST = {
            'email': '*****@*****.**',
            'password': '******',
            'password-confirmation': 'secret2'
        }

        response = sign_up(request)
        
        render.assert_called_once_with(request, 'brent/sign-in.html', {'sign_up_email': '*****@*****.**', 'sign_up_errors': ['Password confirmation does not match']})
        response = render.return_value
Esempio n. 3
0
    def test_creates_user_object_with_email_and_password(self, User):
        ''' it should create and save a user object with the email and password provided '''
        request = mock.Mock()
        request.POST = {
            'email': '*****@*****.**',
            'password': '******',
            'password-confirmation': 'secret'
        }
        User.objects.filter.return_value = []

        response = sign_up(request)

        User.objects.create_user.assert_called_once_with(username='******', password='******')
Esempio n. 4
0
    def test_creates_user_object_with_email_and_password(self, User):
        ''' it should create and save a user object with the email and password provided '''
        request = mock.Mock()
        request.POST = {
            'email': '*****@*****.**',
            'password': '******',
            'password-confirmation': 'secret'
        }
        User.objects.filter.return_value = []

        response = sign_up(request)

        User.objects.create_user.assert_called_once_with(
            username='******', password='******')
Esempio n. 5
0
    def test_renders_sign_in_page_with_context_when_error_occurs(self, render, User):
        '''it should return the sign_in page with the context when sign up fails '''
        request = mock.Mock()
        request.POST = {
            'email': '*****@*****.**',
            'password': '******',
            'password-confirmation': 'secret'
        }
        User.objects.create_user.side_effect = Exception('sign_up failure')

        response = sign_up(request)

        render.assert_called_once_with(request, 'brent/sign-in.html', {'sign_up_email': '*****@*****.**', 'sign_up_errors': ['sign_up failure']})
        response = render.return_value
Esempio n. 6
0
    def test_if_user_exists_already_raise_error(self, render, User):
        User.objects.filter.return_value = [mock.Mock()]
        request = mock.Mock()
        request.POST = {
            'email': '*****@*****.**',
            'password': '******',
            'password-confirmation': 'secret'
        }

        response = sign_up(request)

        render.assert_called_once_with(
            request, 'brent/sign-in.html', {
                'sign_up_email': '*****@*****.**',
                'sign_up_errors': ['This email address is already registered']
            })
Esempio n. 7
0
    def test_raises_error_when_passwords_do_not_match(self, render, User):
        ''' it should raise an error when the password and password-confirmation do not match '''
        request = mock.Mock()
        request.POST = {
            'email': '*****@*****.**',
            'password': '******',
            'password-confirmation': 'secret2'
        }

        response = sign_up(request)

        render.assert_called_once_with(
            request, 'brent/sign-in.html', {
                'sign_up_email': '*****@*****.**',
                'sign_up_errors': ['Password confirmation does not match']
            })
        response = render.return_value
Esempio n. 8
0
    def test_renders_sign_in_page_with_context_when_error_occurs(
            self, render, User):
        '''it should return the sign_in page with the context when sign up fails '''
        request = mock.Mock()
        request.POST = {
            'email': '*****@*****.**',
            'password': '******',
            'password-confirmation': 'secret'
        }
        User.objects.create_user.side_effect = Exception('sign_up failure')

        response = sign_up(request)

        render.assert_called_once_with(
            request, 'brent/sign-in.html', {
                'sign_up_email': '*****@*****.**',
                'sign_up_errors': ['sign_up failure']
            })
        response = render.return_value