/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 breezy/plugins/launchpad/test_account.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    def test_get_lp_login_unconfigured(self):
27
27
        # Test that get_lp_login() returns None if no username has
28
28
        # been configured.
29
 
        my_config = config.MemoryStack(b'')
 
29
        my_config = config.MemoryStack('')
30
30
        self.assertEqual(None, account.get_lp_login(my_config))
31
31
 
32
32
    def test_get_lp_login(self):
33
33
        # Test that get_lp_login() returns the configured username
34
34
        my_config = config.MemoryStack(
35
 
            b'[DEFAULT]\nlaunchpad_username=test-user\n')
 
35
            '[DEFAULT]\nlaunchpad_username=test-user\n')
36
36
        self.assertEqual('test-user', account.get_lp_login(my_config))
37
37
 
38
38
    def test_set_lp_login(self):
39
39
        # Test that set_lp_login() updates the config file.
40
 
        my_config = config.MemoryStack(b'')
 
40
        my_config = config.MemoryStack('')
41
41
        self.assertEqual(None, my_config.get('launchpad_username'))
42
42
        account.set_lp_login('test-user', my_config)
43
43
        self.assertEqual(
53
53
        # Test formatting of NoRegisteredSSHKeys exception
54
54
        error = account.NoRegisteredSSHKeys(user='test-user')
55
55
        self.assertEqualDiff('The user test-user has not registered any '
56
 
                             'SSH keys with Launchpad.\n'
57
 
                             'See <https://launchpad.net/people/+me>',
58
 
                             str(error))
 
56
            'SSH keys with Launchpad.\n'
 
57
            'See <https://launchpad.net/people/+me>',
 
58
            str(error))
59
59
 
60
60
    def test_set_lp_login_updates_authentication_conf(self):
61
61
        self.assertIs(None, account._get_auth_user())
92
92
        account._set_global_option('bar')
93
93
        e = self.assertRaises(account.MismatchedUsernames,
94
94
                              account.get_lp_login)
95
 
        self.assertEqual('breezy.conf and authentication.conf disagree about'
96
 
                         ' launchpad account name.  Please re-run launchpad-login.', str(e))
 
95
        self.assertEqual('bazaar.conf and authentication.conf disagree about'
 
96
            ' launchpad account name.  Please re-run launchpad-login.', str(e))
97
97
 
98
98
 
99
99
class CheckAccountTests(TestCaseWithMemoryTransport):
101
101
    def test_check_lp_login_valid_user(self):
102
102
        transport = self.get_transport()
103
103
        transport.mkdir('~test-user')
104
 
        transport.put_bytes('~test-user/+sshkeys', b'some keys here')
 
104
        transport.put_bytes('~test-user/+sshkeys', 'some keys here')
105
105
        account.check_lp_login('test-user', transport)
106
106
 
107
107
    def test_check_lp_login_no_user(self):
112
112
    def test_check_lp_login_no_ssh_keys(self):
113
113
        transport = self.get_transport()
114
114
        transport.mkdir('~test-user')
115
 
        transport.put_bytes('~test-user/+sshkeys', b'')
 
115
        transport.put_bytes('~test-user/+sshkeys', '')
116
116
        self.assertRaises(account.NoRegisteredSSHKeys,
117
117
                          account.check_lp_login, 'test-user', transport)