~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/test_account.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-23 19:45:15 UTC
  • mto: This revision was merged to the branch mainline in revision 6486.
  • Revision ID: jelmer@samba.org-20120223194515-1ctgfzj362m0tu0k
Use bzrdir.controldir for generic access to control directories.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for Launchpad user ID management functions."""
18
18
 
19
 
from cStringIO import StringIO
20
 
 
21
19
from bzrlib import config
22
20
from bzrlib.tests import TestCaseInTempDir, TestCaseWithMemoryTransport
23
21
from bzrlib.plugins.launchpad import account
25
23
 
26
24
class LaunchpadAccountTests(TestCaseInTempDir):
27
25
 
28
 
    def setup_config(self, text):
29
 
        my_config = config.GlobalConfig.from_string(text)
30
 
        return my_config
31
 
 
32
26
    def test_get_lp_login_unconfigured(self):
33
27
        # Test that get_lp_login() returns None if no username has
34
28
        # been configured.
35
 
        my_config = self.setup_config('')
 
29
        my_config = config.MemoryStack('')
36
30
        self.assertEqual(None, account.get_lp_login(my_config))
37
31
 
38
32
    def test_get_lp_login(self):
39
33
        # Test that get_lp_login() returns the configured username
40
 
        my_config = self.setup_config(
 
34
        my_config = config.MemoryStack(
41
35
            '[DEFAULT]\nlaunchpad_username=test-user\n')
42
36
        self.assertEqual('test-user', account.get_lp_login(my_config))
43
37
 
44
38
    def test_set_lp_login(self):
45
39
        # Test that set_lp_login() updates the config file.
46
 
        my_config = self.setup_config('')
47
 
        self.assertEqual(None, my_config.get_user_option('launchpad_username'))
 
40
        my_config = config.MemoryStack('')
 
41
        self.assertEqual(None, my_config.get('launchpad_username'))
48
42
        account.set_lp_login('test-user', my_config)
49
43
        self.assertEqual(
50
 
            'test-user', my_config.get_user_option('launchpad_username'))
 
44
            'test-user', my_config.get('launchpad_username'))
51
45
 
52
46
    def test_unknown_launchpad_username(self):
53
47
        # Test formatting of UnknownLaunchpadUsername exception