~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

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