46
46
# as to isolate out test logger from other tests.
47
47
self.log_mock.stop()
49
def test_name_logic(self):
50
self.assertEqual('', make_fullname())
51
self.assertEqual('', make_fullname(irrelevant_key='foo'))
52
self.assertEqual('Bob', make_fullname(**dict(firstName='Bob')))
53
self.assertEqual('LastOnly', make_fullname(**dict(lastName='LastOnly')))
56
make_fullname(**dict(firstName='Bob', lastName='Loblaw')))
59
make_fullname(**dict(firstName='Bob', lastName='Loblaw',
49
62
@mock.patch('friends.utils.authentication.manager')
50
63
@mock.patch('friends.utils.authentication.Accounts')
51
64
@mock.patch.dict('friends.utils.authentication.__dict__', LOGIN_TIMEOUT=1)
97
110
'&authToken=-LNy&trk=api*a26127*s26893*',
98
111
1, False, '', '', '', '', '', '', '', 0.0, 0.0])
100
@mock.patch('friends.utils.base.Base._create_contact')
101
def test_create_contact(self, base_mock):
102
self.protocol._create_contact(
103
dict(id='jb89', firstName='Joe', lastName='Blow'))
104
base_mock.assert_called_once_with(
106
{'X-URIS': '', 'linkedin-id': 'jb89', 'linkedin-name': 'Joe Blow'})
108
113
@mock.patch('friends.utils.http.Soup.Message',
109
114
FakeSoupMessage('friends.tests.data', 'linkedin_contacts.json'))
110
115
@mock.patch('friends.protocols.linkedin.LinkedIn._login',
118
123
self.assertEqual(
121
{'siteStandardProfileRequest':
122
{'url': 'https://www.linkedin.com'},
123
'pictureUrl': 'http://m.c.lnkd.licdn.com',
124
'apiStandardProfileRequest':
125
{'url': 'http://api.linkedin.com',
126
'headers': {'_total': 1, 'values':
127
[{'value': 'name:', 'name': 'x-li-auth-token'}]}},
128
'industry': 'Computer Network Security',
131
'headline': 'Unix Administrator at NVIDIA',
132
'location': {'name': 'Pune Area, India',
133
'country': {'code': 'in'}},
137
{'siteStandardProfileRequest':
138
{'url': 'https://www.linkedin.com'},
139
'pictureUrl': 'http://m.c.lnkd.licdn.com',
140
'apiStandardProfileRequest':
141
{'url': 'http://api.linkedin.com',
142
'headers': {'_total': 1, 'values':
143
[{'value': 'name:', 'name': 'x-li-auth-token'}]}},
144
'industry': 'Food Production',
147
'headline': 'Recent Graduate, Simon Fraser University',
148
'location': {'name': 'Vancouver, Canada Area',
149
'country': {'code': 'ca'}},
153
{'siteStandardProfileRequest':
154
{'url': 'https://www.linkedin.com'},
155
'pictureUrl': 'http://m.c.lnkd.licdn.com',
156
'apiStandardProfileRequest':
157
{'url': 'http://api.linkedin.com',
158
'headers': {'_total': 1, 'values':
159
[{'value': 'name:', 'name': 'x-li-auth-token'}]}},
160
'industry': 'Computer Software',
163
'headline': 'Technical Lead at Canonical Ltd.',
164
'location': {'name': 'Auckland, New Zealand',
165
'country': {'code': 'nz'}},
169
{'siteStandardProfileRequest':
170
{'url': 'https://www.linkedin.com'},
171
'pictureUrl': 'http://m.c.lnkd.licdn.com',
172
'apiStandardProfileRequest':
173
{'url': 'http://api.linkedin.com',
174
'headers': {'_total': 1, 'values':
175
[{'value': 'name:', 'name': 'x-li-auth-token'}]}},
176
'industry': 'Photography',
179
'headline': 'Sales manager at McBain Camera',
180
'location': {'name': 'Edmonton, Canada Area',
181
'country': {'code': 'ca'}},
126
{'X-URIS': 'https://www.linkedin.com',
127
'X-FOLKS-WEB-SERVICES-IDS': {
128
'linkedin-id': 'IFDI',
129
'remote-full-name': 'H A'},
130
'linkedin-name': 'H A',
131
'linkedin-id': 'IFDI'}),
133
{'X-URIS': 'https://www.linkedin.com',
134
'X-FOLKS-WEB-SERVICES-IDS': {
135
'linkedin-id': 'AefF',
136
'remote-full-name': 'C A'},
137
'linkedin-name': 'C A',
138
'linkedin-id': 'AefF'}),
140
{'X-URIS': 'https://www.linkedin.com',
141
'X-FOLKS-WEB-SERVICES-IDS': {
142
'linkedin-id': 'DFdV',
143
'remote-full-name': 'R A'},
144
'linkedin-name': 'R A',
145
'linkedin-id': 'DFdV'}),
147
{'X-URIS': 'https://www.linkedin.com',
148
'X-FOLKS-WEB-SERVICES-IDS': {
149
'linkedin-id': 'xkBU',
150
'remote-full-name': 'A Z'},
151
'linkedin-name': 'A Z',
152
'linkedin-id': 'xkBU'})])