5
sys.path.insert(0,"../")
9
from softwarecenter.backend.restfulclient import (UbuntuSSOAPIFake,
11
get_ubuntu_sso_backend,
14
class TestSSOAPI(unittest.TestCase):
15
""" tests the ubuntu sso backend stuff """
17
def test_fake_and_real_provide_similar_methods(self):
18
""" test if the real and fake sso provide the same functions """
19
sso_real = UbuntuSSOAPI
20
sso_fake = UbuntuSSOAPIFake
21
# ensure that both fake and real implement the same methods
23
set([x for x in dir(sso_real) if not x.startswith("_")]),
24
set([x for x in dir(sso_fake) if not x.startswith("_")]))
26
def test_get_ubuntu_backend(self):
27
token = { 'token' : 'tokenvalue',
28
'token_secret' : 'tokensecretvalue',
29
'consumer_key' : 'consumerkeyvalue',
30
'consumer_secret' : 'consumersecretvalue',
32
# test that we get the real one
33
self.assertEqual(type(get_ubuntu_sso_backend(token)),
35
# test that we get the fake one
36
os.environ["SOFTWARE_CENTER_FAKE_REVIEW_API"] = "1"
37
self.assertEqual(type(get_ubuntu_sso_backend(token)),
39
# clean the environment
40
del os.environ["SOFTWARE_CENTER_FAKE_REVIEW_API"]
43
if __name__ == "__main__":
45
logging.basicConfig(level=logging.DEBUG)