~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_whoami.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-01 19:18:09 UTC
  • mfrom: (6459 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6460.
  • Revision ID: jelmer@samba.org-20120201191809-xn340a5i5v4fqsfu
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import bzrlib
21
21
from bzrlib import (
22
 
    branch,
23
22
    config,
24
23
    errors,
25
24
    tests,
51
50
        out = self.run_bzr("whoami --email 'foo <foo@example.com>'", 3)[0]
52
51
        self.assertEquals("", out)
53
52
 
54
 
    def set_branch_email(self, b, email):
55
 
        b.get_config_stack().set('email', email)
56
 
 
57
53
    def test_whoami_branch(self):
58
54
        """branch specific user identity works."""
59
55
        wt = self.make_branch_and_tree('.')
60
56
        b = bzrlib.branch.Branch.open('.')
61
 
        self.set_branch_email(b, 'Branch Identity <branch@identi.ty>')
 
57
        b.get_config_stack().set('email', 'Branch Identity <branch@identi.ty>')
62
58
        self.assertWhoAmI('Branch Identity <branch@identi.ty>')
63
59
        self.assertWhoAmI('branch@identi.ty', '--email')
64
60
 
83
79
        """
84
80
        wt = self.make_branch_and_tree('.')
85
81
        b = bzrlib.branch.Branch.open('.')
86
 
        self.set_branch_email(b, u'Branch Identity \u20ac <branch@identi.ty>')
 
82
        b.get_config_stack().set(
 
83
            'email', u'Branch Identity \u20ac ' + '<branch@identi.ty>')
87
84
        self.assertWhoAmI('Branch Identity ? <branch@identi.ty>',
88
85
                          encoding='ascii')
89
86
        self.assertWhoAmI('branch@identi.ty', '--email',
103
100
        self.overrideEnv('EMAIL', None)
104
101
        self.overrideEnv('BZR_EMAIL', None)
105
102
        # Also, make sure that it's not inferred from mailname.
106
 
        self.overrideAttr(config, '_auto_user_id', lambda: (None, None))
 
103
        self.overrideAttr(config, '_auto_user_id',
 
104
            lambda: (None, None))
107
105
        out, err = self.run_bzr(['whoami'], 3)
108
106
        self.assertContainsRe(err, 'Unable to determine your name')
109
107
 
110
108
    def test_whoami_directory(self):
111
109
        """Test --directory option."""
112
110
        wt = self.make_branch_and_tree('subdir')
113
 
        self.set_branch_email(wt.branch, 'Branch Identity <branch@identi.ty>')
 
111
        c = wt.branch.get_config_stack()
 
112
        c.set('email', 'Branch Identity <branch@identi.ty>')
114
113
        self.assertWhoAmI('Branch Identity <branch@identi.ty>',
115
114
                          '--directory', 'subdir')
116
115
        self.run_bzr(['whoami', '--directory', 'subdir', '--branch',
117
116
                      'Changed Identity <changed@identi.ty>'])
118
 
        # Refresh wt as 'whoami' modified it
119
 
        wt = wt.bzrdir.open_workingtree()
120
117
        c = wt.branch.get_config_stack()
121
118
        self.assertEquals('Changed Identity <changed@identi.ty>',
122
119
                          c.get('email'))
124
121
    def test_whoami_remote_directory(self):
125
122
        """Test --directory option with a remote directory."""
126
123
        wt = self.make_branch_and_tree('subdir')
127
 
        self.set_branch_email(wt.branch, 'Branch Identity <branch@identi.ty>')
 
124
        c = wt.branch.get_config_stack()
 
125
        c.set('email', 'Branch Identity <branch@identi.ty>')
128
126
        url = self.get_readonly_url() + '/subdir'
129
127
        self.assertWhoAmI('Branch Identity <branch@identi.ty>',
130
128
                          '--directory', url)
133
131
                      'Changed Identity <changed@identi.ty>'])
134
132
        # The identity has been set in the branch config (but not the global
135
133
        # config)
136
 
        c = branch.Branch.open(url).get_config_stack()
 
134
        c = wt.branch.get_config_stack()
137
135
        self.assertEquals('Changed Identity <changed@identi.ty>',
138
136
                          c.get('email'))
139
137
        # Ensuring that the value does not come from the bazaar.conf file