Example #1
0
    def test_associate_user_raise_exception(self):
        create_sa = mock.Mock(side_effect=Exception())
        self.backend.strategy.storage.user.create_social_auth = create_sa
        self.backend.strategy.storage.is_integrity_error = mock.Mock(
            return_value=False)

        with self.assertRaises(Exception):
            associate_user(self.backend,
                           self.details,
                           '*****@*****.**',
                           user=self.user)
Example #2
0
    def test_associate_user_raise_exception(self):
        create_sa = mock.Mock(side_effect=Exception())
        self.backend.strategy.storage.user.create_social_auth = create_sa
        self.backend.strategy.storage.is_integrity_error = mock.Mock(return_value=False)

        with self.assertRaises(Exception):
            associate_user(
                self.backend,
                self.details,
                '*****@*****.**',
                user=self.user
            )
Example #3
0
    def test_associate_user_create_secondary(self):
        self.backend.strategy.storage.user.create_social_auth = mock.Mock(return_value=self.social)

        with mock.patch('psa.pipeline.SecondaryEmail') as mocked:
            save = mock.Mock()
            save.return_value = None
            mocked.return_value = save
            res = associate_user(self.backend, self.details,
                                 '*****@*****.**', user=self.user)
            self.assertEqual(res['social'], self.social)
            self.assertEqual(res['user'], self.social.user)
            self.assertEqual(res['new_association'], True)
Example #4
0
    def test_associate_user_handle_exception(self):
        create_sa = mock.Mock(side_effect=Exception())
        self.backend.strategy.storage.user.create_social_auth = create_sa
        self.backend.strategy.storage.is_integrity_error = mock.Mock(
            return_value=True)

        with mock.patch('psa.pipeline.social_user') as mocked:
            mocked.return_value = mock.Mock()
            res = associate_user(self.backend,
                                 self.details,
                                 '*****@*****.**',
                                 user=self.user)
            self.assertEqual(res, mocked.return_value)
Example #5
0
    def test_associate_user_handle_exception(self):
        create_sa = mock.Mock(side_effect=Exception())
        self.backend.strategy.storage.user.create_social_auth = create_sa
        self.backend.strategy.storage.is_integrity_error = mock.Mock(return_value=True)

        with mock.patch('psa.pipeline.social_user') as mocked:
            mocked.return_value = mock.Mock()
            res = associate_user(
                self.backend,
                self.details,
                '*****@*****.**',
                user=self.user
            )
            self.assertEqual(res, mocked.return_value)
Example #6
0
    def test_associate_user_create_secondary(self):
        self.backend.strategy.storage.user.create_social_auth = mock.Mock(
            return_value=self.social)

        with mock.patch('psa.pipeline.SecondaryEmail') as mocked:
            save = mock.Mock()
            save.return_value = None
            mocked.return_value = save
            res = associate_user(self.backend,
                                 self.details,
                                 '*****@*****.**',
                                 user=self.user)
            self.assertEqual(res['social'], self.social)
            self.assertEqual(res['user'], self.social.user)
            self.assertEqual(res['new_association'], True)