/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2008-10-21 00:49:57 UTC
  • mfrom: (3786 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3787.
  • Revision ID: mbp@sourcefrog.net-20081021004957-hb823jymj6m2nbpw
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
        self.assertEqualDiff('The user test-user has not registered any '
64
64
                             'SSH keys with Launchpad.', str(error))
65
65
 
 
66
    def test_set_lp_login_updates_authentication_conf(self):
 
67
        self.assertEqual([None, None], account._get_auth_user().values())
 
68
        account.set_lp_login('foo')
 
69
        self.assertEqual({'production': 'foo', 'staging': 'foo'},
 
70
                         account._get_auth_user())
 
71
 
 
72
    def test_get_lp_login_does_not_update_for_none_user(self):
 
73
        account.get_lp_login()
 
74
        self.assertEqual([None, None], account._get_auth_user().values())
 
75
 
 
76
    def test_get_lp_login_updates_authentication_conf(self):
 
77
        account._set_global_option('foo')
 
78
        self.assertEqual([None, None], account._get_auth_user().values())
 
79
        account.get_lp_login()
 
80
        self.assertEqual({'production': 'foo', 'staging': 'foo'},
 
81
                         account._get_auth_user())
 
82
 
 
83
    def test_get_lp_login_leaves_existing_credentials(self):
 
84
        auth = config.AuthenticationConfig()
 
85
        auth.set_credentials('Foo', 'bazaar.launchpad.net', 'foo', 'ssh')
 
86
        auth.set_credentials('Bar', 'bazaar.staging.launchpad.net', 'foo',
 
87
                             'ssh')
 
88
        account._set_global_option('foo')
 
89
        account.get_lp_login()
 
90
        auth = config.AuthenticationConfig()
 
91
        credentials = auth.get_credentials('ssh', 'bazaar.launchpad.net')
 
92
        self.assertEqual('Foo', credentials['name'])
 
93
 
 
94
    def test_get_lp_login_errors_on_mismatch(self):
 
95
        account._set_auth_user('foo')
 
96
        account._set_global_option('bar')
 
97
        e = self.assertRaises(account.MismatchedUsernames,
 
98
                              account.get_lp_login)
 
99
        self.assertEqual('bazaar.conf and authentication.conf disagree about'
 
100
            ' launchpad account name.  Please re-run launchpad-login.', str(e))
 
101
 
66
102
 
67
103
class CheckAccountTests(TestCaseWithMemoryTransport):
68
104