~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-01-06 22:44:57 UTC
  • mfrom: (6436 +trunk)
  • mto: (6437.3.11 2.5)
  • mto: This revision was merged to the branch mainline in revision 6444.
  • Revision ID: jelmer@samba.org-20120106224457-re0pcy0fz31xob77
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009, 2010, 2011 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
20
20
import bzrlib
21
21
from bzrlib import (
22
22
    config,
 
23
    errors,
23
24
    tests,
24
25
    )
25
26
 
53
54
        """branch specific user identity works."""
54
55
        wt = self.make_branch_and_tree('.')
55
56
        b = bzrlib.branch.Branch.open('.')
56
 
        b.get_config().set_user_option('email',
57
 
                                       'Branch Identity <branch@identi.ty>')
 
57
        b.get_config_stack().set('email', 'Branch Identity <branch@identi.ty>')
58
58
        self.assertWhoAmI('Branch Identity <branch@identi.ty>')
59
59
        self.assertWhoAmI('branch@identi.ty', '--email')
60
60
 
79
79
        """
80
80
        wt = self.make_branch_and_tree('.')
81
81
        b = bzrlib.branch.Branch.open('.')
82
 
        b.get_config().set_user_option('email', u'Branch Identity \u20ac ' +
83
 
                                       '<branch@identi.ty>')
 
82
        b.get_config_stack().set(
 
83
            'email', u'Branch Identity \u20ac ' + '<branch@identi.ty>')
84
84
        self.assertWhoAmI('Branch Identity ? <branch@identi.ty>',
85
85
                          encoding='ascii')
86
86
        self.assertWhoAmI('branch@identi.ty', '--email',
108
108
    def test_whoami_directory(self):
109
109
        """Test --directory option."""
110
110
        wt = self.make_branch_and_tree('subdir')
111
 
        c = wt.branch.get_config()
112
 
        c.set_user_option('email', 'Branch Identity <branch@identi.ty>')
 
111
        c = wt.branch.get_config_stack()
 
112
        c.set('email', 'Branch Identity <branch@identi.ty>')
113
113
        self.assertWhoAmI('Branch Identity <branch@identi.ty>',
114
114
                          '--directory', 'subdir')
115
115
        self.run_bzr(['whoami', '--directory', 'subdir', '--branch',
116
116
                      'Changed Identity <changed@identi.ty>'])
117
 
        c = wt.branch.get_config()
 
117
        c = wt.branch.get_config_stack()
118
118
        self.assertEquals('Changed Identity <changed@identi.ty>',
119
 
                          c.get_user_option('email'))
 
119
                          c.get('email'))
120
120
 
121
121
    def test_whoami_remote_directory(self):
122
122
        """Test --directory option with a remote directory."""
123
123
        wt = self.make_branch_and_tree('subdir')
124
 
        c = wt.branch.get_config()
125
 
        c.set_user_option('email', 'Branch Identity <branch@identi.ty>')
 
124
        c = wt.branch.get_config_stack()
 
125
        c.set('email', 'Branch Identity <branch@identi.ty>')
126
126
        url = self.get_readonly_url() + '/subdir'
127
127
        self.assertWhoAmI('Branch Identity <branch@identi.ty>',
128
128
                          '--directory', url)
131
131
                      'Changed Identity <changed@identi.ty>'])
132
132
        # The identity has been set in the branch config (but not the global
133
133
        # config)
134
 
        c = wt.branch.get_config()
 
134
        c = wt.branch.get_config_stack()
135
135
        self.assertEquals('Changed Identity <changed@identi.ty>',
136
 
                          c.get_user_option('email'))
137
 
        global_conf = config.GlobalConfig()
138
 
        self.assertEquals(None, global_conf.get_user_option('email'))
 
136
                          c.get('email'))
 
137
        # Ensuring that the value does not come from the bazaar.conf file
 
138
        # itself requires some isolation setup
 
139
        self.overrideEnv('BZR_EMAIL', None)
 
140
        self.overrideEnv('EMAIL', None)
 
141
        self.overrideAttr(config, '_auto_user_id', lambda: (None, None))
 
142
        global_conf = config.GlobalStack()
 
143
        self.assertRaises(errors.NoWhoami, global_conf.get, 'email')
139
144
 
140
145
    def test_whoami_nonbranch_directory(self):
141
146
        """Test --directory mentioning a non-branch directory."""