/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/tests/blackbox/test_whoami.py

  • Committer: Jelmer Vernooij
  • Date: 2018-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Black-box tests for brz whoami."""
19
19
 
 
20
import breezy
20
21
from breezy import (
21
22
    branch,
22
23
    config,
24
25
    tests,
25
26
    )
26
27
 
27
 
from ..test_bedding import override_whoami
28
 
 
29
28
 
30
29
class TestWhoami(tests.TestCaseWithTransport):
31
30
 
34
33
        self.assertEqual('', err)
35
34
        lines = out.splitlines()
36
35
        self.assertLength(1, lines)
37
 
        if isinstance(expected, bytes):
38
 
            expected = expected.decode(kwargs.get('encoding', 'ascii'))
39
36
        self.assertEqual(expected, lines[0].rstrip())
40
37
 
41
38
    def test_whoami_no_args_no_conf(self):
60
57
    def test_whoami_branch(self):
61
58
        """branch specific user identity works."""
62
59
        wt = self.make_branch_and_tree('.')
63
 
        b = branch.Branch.open('.')
 
60
        b = breezy.branch.Branch.open('.')
64
61
        self.set_branch_email(b, 'Branch Identity <branch@identi.ty>')
65
62
        self.assertWhoAmI('Branch Identity <branch@identi.ty>')
66
63
        self.assertWhoAmI('branch@identi.ty', '--email')
75
72
        """verify that an identity can be in utf-8."""
76
73
        self.run_bzr(['whoami', u'Branch Identity \u20ac <branch@identi.ty>'],
77
74
                     encoding='utf-8')
78
 
        self.assertWhoAmI(b'Branch Identity \xe2\x82\xac <branch@identi.ty>',
 
75
        self.assertWhoAmI('Branch Identity \xe2\x82\xac <branch@identi.ty>',
79
76
                          encoding='utf-8')
80
77
        self.assertWhoAmI('branch@identi.ty', '--email')
81
78
 
85
82
        encoding.
86
83
        """
87
84
        wt = self.make_branch_and_tree('.')
88
 
        b = branch.Branch.open('.')
 
85
        b = breezy.branch.Branch.open('.')
89
86
        self.set_branch_email(b, u'Branch Identity \u20ac <branch@identi.ty>')
90
87
        self.assertWhoAmI('Branch Identity ? <branch@identi.ty>',
91
88
                          encoding='ascii')
97
94
        self.make_branch_and_tree('.')
98
95
        display = self.run_bzr(['whoami', 'Branch Identity'])[1]
99
96
        self.assertEqual('"Branch Identity" does not seem to contain an '
100
 
                         'email address.  This is allowed, but not '
101
 
                         'recommended.\n', display)
 
97
                          'email address.  This is allowed, but not '
 
98
                          'recommended.\n', display)
102
99
 
103
100
    def test_whoami_not_set(self):
104
101
        """Ensure whoami error if username is not set and not inferred.
105
102
        """
106
 
        override_whoami(self)
 
103
        self.overrideEnv('EMAIL', None)
 
104
        self.overrideEnv('BRZ_EMAIL', None)
 
105
        # Also, make sure that it's not inferred from mailname.
 
106
        self.overrideAttr(config, '_auto_user_id', lambda: (None, None))
107
107
        out, err = self.run_bzr(['whoami'], 3)
108
108
        self.assertContainsRe(err, 'Unable to determine your name')
109
109
 
119
119
        wt = wt.controldir.open_workingtree()
120
120
        c = wt.branch.get_config_stack()
121
121
        self.assertEqual('Changed Identity <changed@identi.ty>',
122
 
                         c.get('email'))
 
122
                          c.get('email'))
123
123
 
124
124
    def test_whoami_remote_directory(self):
125
125
        """Test --directory option with a remote directory."""
135
135
        # config)
136
136
        c = branch.Branch.open(url).get_config_stack()
137
137
        self.assertEqual('Changed Identity <changed@identi.ty>',
138
 
                         c.get('email'))
 
138
                          c.get('email'))
139
139
        # Ensuring that the value does not come from the breezy.conf file
140
140
        # itself requires some isolation setup
141
 
        override_whoami(self)
 
141
        self.overrideEnv('BRZ_EMAIL', None)
 
142
        self.overrideEnv('EMAIL', None)
 
143
        self.overrideAttr(config, '_auto_user_id', lambda: (None, None))
142
144
        global_conf = config.GlobalStack()
143
 
        self.assertRaises(errors.NoWhoami, global_conf.get, 'email')
 
145
        self.assertRaises(config.NoWhoami, global_conf.get, 'email')
144
146
 
145
147
    def test_whoami_nonbranch_directory(self):
146
148
        """Test --directory mentioning a non-branch directory."""