~mvo/ubuntu-sso-client/strawman-lp711413

« back to all changes in this revision

Viewing changes to ubuntu_sso/tests/test_main.py

  • Committer: natalia.bidart at canonical
  • Date: 2010-06-10 14:34:40 UTC
  • mto: This revision was merged to the branch mainline in revision 537.
  • Revision ID: natalia.bidart@canonical.com-20100610143440-nzqm5ad5g0xd2k29
Making rename of ubuntu.sso to ubuntu_sso to avoid package name clashing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# test_main - tests for ubuntu.sso.main
 
1
# test_main - tests for ubuntu_sso.main
2
2
#
3
3
# Author: Stuart Langridge <stuart.langridge@canonical.com>
4
4
#
19
19
 
20
20
import os, StringIO
21
21
from mocker import MockerTestCase
22
 
from ubuntu.sso import config
23
 
from ubuntu.sso.main import LoginProcessor, BadRealmError
 
22
from ubuntu_sso import config
 
23
from ubuntu_sso.main import LoginProcessor, BadRealmError
24
24
 
25
25
class Realm(MockerTestCase):
26
26
    """Test the realm handling finder"""
27
27
 
28
28
    def test_invalid_realm(self):
29
29
        """Are invalid realms rejected?"""
30
 
                
31
30
        login = LoginProcessor(None, use_libnotify=False)
32
31
        self.assertRaises(BadRealmError, login.login, "bad realm", "key")
33
32
 
34
33
    def test_realms(self):
35
34
        """Are realm URLs correctly retrieved from the config?"""
36
 
        
37
35
        # mock that tmp config file exists
38
36
        tmp_config_file = os.path.realpath(os.path.join(
39
37
          os.path.split(config.__file__)[0], "../../data/oauth_urls"
41
39
        osp = self.mocker.replace("os.path")
42
40
        osp.isfile(tmp_config_file)
43
41
        self.mocker.result(True)
44
 
        
 
42
 
45
43
        sio = StringIO.StringIO("""[default]
46
44
request_token_url = /rtu-default
47
45
user_authorisation_url = /uau-default
64
62
        mock_open = self.mocker.replace(open)
65
63
        mock_open(tmp_config_file)
66
64
        self.mocker.result(sio)
67
 
        
 
65
 
68
66
        self.mocker.replay()
69
 
        
 
67
 
70
68
        login = LoginProcessor(None, use_libnotify=False)
71
 
        
 
69
 
72
70
        # are localhost:XXXX URLs correctly fetched?
73
71
        (rtu, uau, atu, cs) = login.get_config_urls("http://localhost:9876")
74
72
        self.assertEqual(rtu, "http://localhost:9876/rtu-localhost")