Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Hermes
Summary Lists News SCM
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
5 import unittest
6     
7 class FakeGConf(dict):
8     def __init__(self, props=None):
9         dict.__init__(self)
10         if props:
11             for key in props:
12                 self.set_string(key, props[key])
13     def get_string(self, key):
14         try: return self.__getitem__(key)
15         except: return None
16     def set_string(self, key, value):
17         self.__setitem__(key, value)
19 class IntegrationTestLinkedInApi(unittest.TestCase):
20     
21     def setUp(self):
22         self.gconf = FakeGConf({
23                 LinkedInApi.GCONF_API_KEY:'1et4G-VtmtqNfY7gF8PHtxMOf0KNWl9ericlTEtdKJeoA4ubk4wEQwf8lSL8AnYE',
24                 LinkedInApi.GCONF_API_SECRET:'uk--OtmWcxER-Yh6Py5p0VeLPNlDJSMaXj1xfHILoFzrK7fM9eepNo5RbwGdkRo_'})
25         self.testee = LinkedInApi(self.gconf)
28     def test_get_request_token(self):
29         token = self.testee._get_request_token()
30         
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
35         
36         
37     def test_get_authorize_url(self):
38         request_token = self.testee._get_request_token()
39         url = self.testee._get_authorize_url(request_token)
40         
41         assert url is not None
42         assert "linkedin.com" in url
43     
44     
45     def test_verify_verifier_opens_browser(self):
46         self.verifier = "IllegalVerifier"
47         authenticate_threw_exception = False
49         try:
50         #if True:
51             self.testee.authenticate(self._need_auth_cb, self._block_for_auth)
52             assert False # should always go to except clause
53         except:
54             authenticate_threw_exception = True
55         
56         assert self.need_auth_called
57         assert self.block_for_auth_called
58         assert self.block_for_auth_show_input_field
59         assert authenticate_threw_exception
62     def _need_auth_cb(self):
63         self.need_auth_called = True
66     def _block_for_auth(self, show_input_field):
67         self.block_for_auth_called = True
68         self.block_for_auth_show_input_field = show_input_field
69         return self.verifier
71     
72 if __name__ == '__main__':
73     unittest.main()

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment