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

  • Committer: Robert Collins
  • Date: 2007-07-15 15:40:37 UTC
  • mto: (2592.3.33 repository)
  • mto: This revision was merged to the branch mainline in revision 2624.
  • Revision ID: robertc@robertcollins.net-20070715154037-3ar8g89decddc9su
Make GraphIndex accept nodes as key, value, references, so that the method
signature is closer to what a simple key->value index delivers. Also
change the behaviour when the reference list count is zero to accept
key, value as nodes, and emit key, value to make it identical in that case
to a simple key->value index. This may not be a good idea, but for now it
seems ok.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
18
"""Black-box tests for bzr whoami."""
20
20
import os
21
21
 
22
22
import bzrlib
23
 
from bzrlib import osutils
24
23
from bzrlib.branch import Branch
25
24
from bzrlib.tests.blackbox import ExternalBase
26
25
 
36
35
        out = self.run_bzr("whoami --email")[0]
37
36
        self.assertTrue(len(out) > 0)
38
37
        self.assertEquals(1, out.count('@'))
39
 
 
 
38
        
40
39
    def test_whoami_branch(self):
41
40
        """branch specific user identity works."""
42
41
        wt = self.make_branch_and_tree('.')
46
45
        bzr_email = os.environ.get('BZR_EMAIL')
47
46
        if bzr_email is not None:
48
47
            del os.environ['BZR_EMAIL']
 
48
        bzremail = os.environ.get('BZREMAIL')
 
49
        if bzremail is not None:
 
50
            del os.environ['BZREMAIL']
49
51
        try:
50
52
            whoami = self.run_bzr("whoami")[0]
51
53
            self.assertEquals('Branch Identity <branch@identi.ty>\n', whoami)
52
54
            whoami_email = self.run_bzr("whoami --email")[0]
53
55
            self.assertEquals('branch@identi.ty\n', whoami_email)
54
56
 
55
 
            # Verify that the environment variable overrides the value
 
57
            # Verify that the environment variable overrides the value 
56
58
            # in the file
57
59
            os.environ['BZR_EMAIL'] = 'Different ID <other@environ.ment>'
58
60
            whoami = self.run_bzr("whoami")[0]
60
62
            whoami_email = self.run_bzr("whoami --email")[0]
61
63
            self.assertEquals('other@environ.ment\n', whoami_email)
62
64
            del os.environ['BZR_EMAIL']
 
65
            os.environ['BZREMAIL'] = 'Yet Another ID <yetother@environ.ment>'
 
66
            whoami, warn = self.run_bzr("whoami")
 
67
            self.assertEquals('Yet Another ID <yetother@environ.ment>\n', whoami)
 
68
            self.assertTrue(len(warn) > 0)
 
69
            del os.environ['BZREMAIL']
63
70
        finally:
64
71
            if bzr_email is not None:
65
72
                os.environ['BZR_EMAIL'] = bzr_email
 
73
            if bzremail is not None:
 
74
                os.environ['BZREMAIL'] = bzremail
66
75
 
67
76
    def test_whoami_utf8(self):
68
77
        """verify that an identity can be in utf-8."""
112
121
        self.assertEquals('"Branch Identity" does not seem to contain an '
113
122
                          'email address.  This is allowed, but not '
114
123
                          'recommended.\n', display)
115
 
 
116
 
    def test_whoami_not_set(self):
117
 
        """Ensure whoami error if username is not set.
118
 
        """
119
 
        osutils.set_or_unset_env('EMAIL', None)
120
 
        osutils.set_or_unset_env('BZR_EMAIL', None)
121
 
        out, err = self.run_bzr(['whoami'], 3)
122
 
        self.assertContainsRe(err, 'Unable to determine your name')