/usr/lib/python3/dist-packages/social/tests/actions/test_associate.py is in python3-social-auth 0.2.13-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | import json
from social.exceptions import AuthAlreadyAssociated
from social.tests.models import User
from social.tests.actions.actions import BaseActionTest
class AssociateActionTest(BaseActionTest):
expected_username = 'foobar'
def setUp(self):
super(AssociateActionTest, self).setUp()
self.user = User(username='foobar', email='foo@bar.com')
self.backend.strategy.session_set('username', self.user.username)
def test_associate(self):
self.do_login()
self.assertTrue(len(self.user.social), 1)
self.assertEqual(self.user.social[0].provider, 'github')
def test_associate_with_partial_pipeline(self):
self.do_login_with_partial_pipeline()
self.assertEqual(len(self.user.social), 1)
self.assertEqual(self.user.social[0].provider, 'github')
class MultipleAccountsTest(AssociateActionTest):
alternative_user_data_body = json.dumps({
'login': 'foobar2',
'id': 2,
'avatar_url': 'https://github.com/images/error/foobar2_happy.gif',
'gravatar_id': 'somehexcode',
'url': 'https://api.github.com/users/foobar2',
'name': 'monalisa foobar2',
'company': 'GitHub',
'blog': 'https://github.com/blog',
'location': 'San Francisco',
'email': 'foo@bar.com',
'hireable': False,
'bio': 'There once was...',
'public_repos': 2,
'public_gists': 1,
'followers': 20,
'following': 0,
'html_url': 'https://github.com/foobar2',
'created_at': '2008-01-14T04:33:35Z',
'type': 'User',
'total_private_repos': 100,
'owned_private_repos': 100,
'private_gists': 81,
'disk_usage': 10000,
'collaborators': 8,
'plan': {
'name': 'Medium',
'space': 400,
'collaborators': 10,
'private_repos': 20
}
})
def test_multiple_social_accounts(self):
self.do_login()
self.do_login(user_data_body=self.alternative_user_data_body)
self.assertEqual(len(self.user.social), 2)
self.assertEqual(self.user.social[0].provider, 'github')
self.assertEqual(self.user.social[1].provider, 'github')
class AlreadyAssociatedErrorTest(BaseActionTest):
def setUp(self):
super(AlreadyAssociatedErrorTest, self).setUp()
self.user1 = User(username='foobar', email='foo@bar.com')
self.user = None
def tearDown(self):
super(AlreadyAssociatedErrorTest, self).tearDown()
self.user1 = None
self.user = None
def test_already_associated_error(self):
self.user = self.user1
self.do_login()
self.user = User(username='foobar2', email='foo2@bar2.com')
with self.assertRaisesRegexp(AuthAlreadyAssociated,
'This github account is already in use.'):
self.do_login()
|