1 from org.maemo.hermes.engine.linkedin.service import Service
2 from org.maemo.hermes.engine.linkedin.api import LinkedInApi
3 from org.maemo.hermes.engine.names import canonical
4 from org.maemo.hermes.engine.friend import Friend
8 def __init__(self, props=None):
12 self.set_string(key, props[key])
13 def get_string(self, key):
14 try: return self.__getitem__(key)
16 def set_string(self, key, value):
17 self.__setitem__(key, value)
19 class IntegrationTestLinkedInApi(unittest.TestCase):
22 self.gconf = FakeGConf({
23 '/apps/maemo/hermes/linkedin_key':'1et4G-VtmtqNfY7gF8PHtxMOf0KNWl9ericlTEtdKJeoA4ubk4wEQwf8lSL8AnYE',
24 '/apps/maemo/hermes/linkedin_secret':'uk--OtmWcxER-Yh6Py5p0VeLPNlDJSMaXj1xfHILoFzrK7fM9eepNo5RbwGdkRo_'})
25 self.testee = LinkedInApi(self.gconf)
28 def test_get_request_token(self):
29 token = self.testee._get_request_token()
31 assert token is not None
32 assert token.callback_confirmed == "true"
33 assert token.key is not None
34 assert token.secret is not None
37 def test_get_authorize_url(self):
38 request_token = self.testee._get_request_token()
39 url = self.testee._get_authorize_url(request_token)
41 assert url is not None
42 assert "linkedin.com" in url
45 def test_verify_verifier_opens_browser(self):
46 self.verifier = "IllegalVerifier"
47 authenticate_threw_exception = False
51 self.testee.authenticate(self._need_auth_cb, self._block_for_auth)
52 assert False # should always go to except clause
54 authenticate_threw_exception = True
56 assert authenticate_threw_exception
57 assert self.need_auth_called
58 assert self.block_for_auth_called
59 assert self.block_for_auth_show_input_field
62 def _need_auth_cb(self):
63 self.need_auth_called = True
66 def _block_for_auth(self, show_input_field, url=None):
67 self.block_for_auth_called = True
68 self.block_for_auth_show_input_field = show_input_field
69 self.block_for_auth_url = url
73 if __name__ == '__main__':