/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: John Arbash Meinel
  • Date: 2006-07-18 18:57:54 UTC
  • mto: This revision was merged to the branch mainline in revision 1868.
  • Revision ID: john@arbash-meinel.com-20060718185754-4007745748e28db9
Commit timestamp restricted to 1ms precision.

The old code would restrict to 1s resolution if the timestamp was
supplied, while it preserved full resolution if the timestamp was
auto generated. Now both paths preserve only 1ms resolution.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006 by 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
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."""
32
32
        self.assertTrue(len(out) > 0)
33
33
        self.assertEquals(1, out.count('@'))
34
34
 
35
 
        out = self.run_bzr("whoami --email")[0]
 
35
        out = self.run_bzr("whoami", "--email")[0]
36
36
        self.assertTrue(len(out) > 0)
37
37
        self.assertEquals(1, out.count('@'))
38
 
 
 
38
        
39
39
    def test_whoami_branch(self):
40
40
        """branch specific user identity works."""
41
41
        wt = self.make_branch_and_tree('.')
42
42
        b = bzrlib.branch.Branch.open('.')
43
43
        b.get_config().set_user_option('email',
44
44
                                       'Branch Identity <branch@identi.ty>')
45
 
        bzr_email = os.environ.get('BZR_EMAIL')
 
45
        bzr_email = os.environ.get('BZREMAIL')
46
46
        if bzr_email is not None:
47
 
            del os.environ['BZR_EMAIL']
 
47
            del os.environ['BZREMAIL']
48
48
        try:
49
49
            whoami = self.run_bzr("whoami")[0]
50
50
            self.assertEquals('Branch Identity <branch@identi.ty>\n', whoami)
51
 
            whoami_email = self.run_bzr("whoami --email")[0]
 
51
            whoami_email = self.run_bzr("whoami", "--email")[0]
52
52
            self.assertEquals('branch@identi.ty\n', whoami_email)
53
53
 
54
 
            # Verify that the environment variable overrides the value
 
54
            # Verify that the environment variable overrides the value 
55
55
            # in the file
56
 
            os.environ['BZR_EMAIL'] = 'Different ID <other@environ.ment>'
 
56
            os.environ['BZREMAIL'] = 'Different ID <other@environ.ment>'
57
57
            whoami = self.run_bzr("whoami")[0]
58
58
            self.assertEquals('Different ID <other@environ.ment>\n', whoami)
59
 
            whoami_email = self.run_bzr("whoami --email")[0]
 
59
            whoami_email = self.run_bzr("whoami", "--email")[0]
60
60
            self.assertEquals('other@environ.ment\n', whoami_email)
61
 
            del os.environ['BZR_EMAIL']
62
61
        finally:
63
62
            if bzr_email is not None:
64
 
                os.environ['BZR_EMAIL'] = bzr_email
 
63
                os.environ['BZREMAIL'] = bzr_email
65
64
 
66
65
    def test_whoami_utf8(self):
67
66
        """verify that an identity can be in utf-8."""
68
67
        wt = self.make_branch_and_tree('.')
69
 
        self.run_bzr(['whoami', u'Branch Identity \u20ac <branch@identi.ty>'],
 
68
        self.run_bzr('whoami', u'Branch Identity \u20ac <branch@identi.ty>',
70
69
                     encoding='utf-8')
71
 
        bzr_email = os.environ.get('BZR_EMAIL')
 
70
        bzr_email = os.environ.get('BZREMAIL')
72
71
        if bzr_email is not None:
73
 
            del os.environ['BZR_EMAIL']
 
72
            del os.environ['BZREMAIL']
74
73
        try:
75
74
            whoami = self.run_bzr("whoami", encoding='utf-8')[0]
76
75
            self.assertEquals('Branch Identity \xe2\x82\xac ' +
77
76
                              '<branch@identi.ty>\n', whoami)
78
 
            whoami_email = self.run_bzr("whoami --email",
 
77
            whoami_email = self.run_bzr("whoami", "--email",
79
78
                                        encoding='utf-8')[0]
80
79
            self.assertEquals('branch@identi.ty\n', whoami_email)
81
80
        finally:
82
81
            if bzr_email is not None:
83
 
                os.environ['BZR_EMAIL'] = bzr_email
 
82
                os.environ['BZREMAIL'] = bzr_email
84
83
 
85
84
    def test_whoami_ascii(self):
86
85
        """
91
90
        b = bzrlib.branch.Branch.open('.')
92
91
        b.get_config().set_user_option('email', u'Branch Identity \u20ac ' +
93
92
                                       '<branch@identi.ty>')
94
 
        bzr_email = os.environ.get('BZR_EMAIL')
 
93
        bzr_email = os.environ.get('BZREMAIL')
95
94
        if bzr_email is not None:
96
 
            del os.environ['BZR_EMAIL']
 
95
            del os.environ['BZREMAIL']
97
96
        try:
98
97
            whoami = self.run_bzr("whoami", encoding='ascii')[0]
99
98
            self.assertEquals('Branch Identity ? <branch@identi.ty>\n', whoami)
100
 
            whoami_email = self.run_bzr("whoami --email",
 
99
            whoami_email = self.run_bzr("whoami", "--email",
101
100
                                        encoding='ascii')[0]
102
101
            self.assertEquals('branch@identi.ty\n', whoami_email)
103
102
        finally:
104
103
            if bzr_email is not None:
105
 
                os.environ['BZR_EMAIL'] = bzr_email
 
104
                os.environ['BZREMAIL'] = bzr_email
106
105
 
107
106
    def test_warning(self):
108
107
        """verify that a warning is displayed if no email is given."""
109
108
        self.make_branch_and_tree('.')
110
 
        display = self.run_bzr(['whoami', 'Branch Identity'])[1]
 
109
        display = self.run_bzr('whoami', 'Branch Identity')[1]
111
110
        self.assertEquals('"Branch Identity" does not seem to contain an '
112
111
                          'email address.  This is allowed, but not '
113
112
                          'recommended.\n', display)