コード例 #1
0
ファイル: tests.py プロジェクト: karluxd/socraticqs2
    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)
コード例 #2
0
ファイル: views.py プロジェクト: cjlee112/socraticqs2
    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
            )
コード例 #3
0
ファイル: views.py プロジェクト: cjlee112/socraticqs2
    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)
コード例 #4
0
ファイル: tests.py プロジェクト: karluxd/socraticqs2
    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)
コード例 #5
0
ファイル: views.py プロジェクト: cjlee112/socraticqs2
    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)
コード例 #6
0
ファイル: tests.py プロジェクト: karluxd/socraticqs2
    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)