Example #1
0
    def test_create_user_exception_scenario(self):
        """
        Tests sad path - expected exception is thrown, captured and transformed into AuthException subclass instance
        """
        with mock.patch("third_party_auth.pipeline.social_create_user") as patched_social_create_user:
            patched_social_create_user.side_effect = self._raise_email_in_use_exception

            strategy, details, user = mock.Mock(), {'email': '*****@*****.**'}, mock.Mock()

            with self.assertRaises(pipeline.EmailAlreadyInUseException):
                # pylint: disable=redundant-keyword-arg
                pipeline.create_user(strategy, 1, details=details, user=user)
Example #2
0
    def test_create_user_normal_scenario(self):
        """  Tests happy path - user is created and results are returned intact """
        retval = mock.Mock()
        with mock.patch("third_party_auth.pipeline.social_create_user") as patched_social_create_user:
            patched_social_create_user.return_value = retval
            strategy, details, user, idx = mock.Mock(), {'email': '*****@*****.**'}, mock.Mock(), 1

            # pylint: disable=redundant-keyword-arg
            result = pipeline.create_user(strategy, idx, details=details, user=user)

            self.assertEqual(result, retval)