def test_social_validated_not_allowed(self): backend = mock.Mock(**self.attrs) backend.name = 'google-oauth2' uid = '*****@*****.**' with mock.patch('psa.pipeline.not_allowed_to_merge') as mocked: mocked.return_value = True with self.assertRaises(AuthAlreadyAssociated): social_user(backend, uid, user=self.main_user)
def test_social_anonymous(self): backend = mock.Mock(**self.attrs) backend.name = 'google-oauth2' uid = '*****@*****.**' res = social_user(backend, uid, user=self.anonymous) self.assertEqual(res['user'], self.user) self.assertEqual(res['social'], self.social) self.assertEqual(res['is_new'], False) self.assertEqual(res['new_association'], False)
def test_no_social(self): self.attrs = {'strategy.storage.user.get_social_auth.return_value': []} backend = mock.Mock(**self.attrs) backend.name = 'google-oauth2' uid = '*****@*****.**' res = social_user(backend, uid) self.assertEqual(res['user'], None) self.assertEqual(res['social'], []) self.assertEqual(res['is_new'], True) self.assertEqual(res['new_association'], False)
def test_social_validated(self): backend = mock.Mock(**self.attrs) backend.name = 'google-oauth2' uid = '*****@*****.**' with mock.patch('psa.pipeline.not_allowed_to_merge') as mocked: mocked.return_value = False res = social_user(backend, uid, user=self.main_user) self.assertEqual(res['user'], self.main_user) self.assertEqual(res['social'], self.social) self.assertEqual(res['is_new'], False) self.assertEqual(res['new_association'], False)