~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Alexander Belchenko
  • Date: 2006-07-30 16:43:12 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060730164312-b025fd3ff0cee59e
rename  gpl.txt => COPYING.txt

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
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
        
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']
48
 
        bzremail = os.environ.get('BZREMAIL')
49
 
        if bzremail is not None:
50
47
            del os.environ['BZREMAIL']
51
48
        try:
52
49
            whoami = self.run_bzr("whoami")[0]
53
50
            self.assertEquals('Branch Identity <branch@identi.ty>\n', whoami)
54
 
            whoami_email = self.run_bzr("whoami --email")[0]
 
51
            whoami_email = self.run_bzr("whoami", "--email")[0]
55
52
            self.assertEquals('branch@identi.ty\n', whoami_email)
56
53
 
57
54
            # Verify that the environment variable overrides the value 
58
55
            # in the file
59
 
            os.environ['BZR_EMAIL'] = 'Different ID <other@environ.ment>'
 
56
            os.environ['BZREMAIL'] = 'Different ID <other@environ.ment>'
60
57
            whoami = self.run_bzr("whoami")[0]
61
58
            self.assertEquals('Different ID <other@environ.ment>\n', whoami)
62
 
            whoami_email = self.run_bzr("whoami --email")[0]
 
59
            whoami_email = self.run_bzr("whoami", "--email")[0]
63
60
            self.assertEquals('other@environ.ment\n', whoami_email)
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']
70
61
        finally:
71
62
            if bzr_email is not None:
72
 
                os.environ['BZR_EMAIL'] = bzr_email
73
 
            if bzremail is not None:
74
 
                os.environ['BZREMAIL'] = bzremail
 
63
                os.environ['BZREMAIL'] = bzr_email
75
64
 
76
65
    def test_whoami_utf8(self):
77
66
        """verify that an identity can be in utf-8."""
78
67
        wt = self.make_branch_and_tree('.')
79
 
        self.run_bzr(['whoami', u'Branch Identity \u20ac <branch@identi.ty>'],
 
68
        self.run_bzr('whoami', u'Branch Identity \u20ac <branch@identi.ty>',
80
69
                     encoding='utf-8')
81
 
        bzr_email = os.environ.get('BZR_EMAIL')
 
70
        bzr_email = os.environ.get('BZREMAIL')
82
71
        if bzr_email is not None:
83
 
            del os.environ['BZR_EMAIL']
 
72
            del os.environ['BZREMAIL']
84
73
        try:
85
74
            whoami = self.run_bzr("whoami", encoding='utf-8')[0]
86
75
            self.assertEquals('Branch Identity \xe2\x82\xac ' +
87
76
                              '<branch@identi.ty>\n', whoami)
88
 
            whoami_email = self.run_bzr("whoami --email",
 
77
            whoami_email = self.run_bzr("whoami", "--email",
89
78
                                        encoding='utf-8')[0]
90
79
            self.assertEquals('branch@identi.ty\n', whoami_email)
91
80
        finally:
92
81
            if bzr_email is not None:
93
 
                os.environ['BZR_EMAIL'] = bzr_email
 
82
                os.environ['BZREMAIL'] = bzr_email
94
83
 
95
84
    def test_whoami_ascii(self):
96
85
        """
101
90
        b = bzrlib.branch.Branch.open('.')
102
91
        b.get_config().set_user_option('email', u'Branch Identity \u20ac ' +
103
92
                                       '<branch@identi.ty>')
104
 
        bzr_email = os.environ.get('BZR_EMAIL')
 
93
        bzr_email = os.environ.get('BZREMAIL')
105
94
        if bzr_email is not None:
106
 
            del os.environ['BZR_EMAIL']
 
95
            del os.environ['BZREMAIL']
107
96
        try:
108
97
            whoami = self.run_bzr("whoami", encoding='ascii')[0]
109
98
            self.assertEquals('Branch Identity ? <branch@identi.ty>\n', whoami)
110
 
            whoami_email = self.run_bzr("whoami --email",
 
99
            whoami_email = self.run_bzr("whoami", "--email",
111
100
                                        encoding='ascii')[0]
112
101
            self.assertEquals('branch@identi.ty\n', whoami_email)
113
102
        finally:
114
103
            if bzr_email is not None:
115
 
                os.environ['BZR_EMAIL'] = bzr_email
 
104
                os.environ['BZREMAIL'] = bzr_email
116
105
 
117
106
    def test_warning(self):
118
107
        """verify that a warning is displayed if no email is given."""
119
108
        self.make_branch_and_tree('.')
120
 
        display = self.run_bzr(['whoami', 'Branch Identity'])[1]
 
109
        display = self.run_bzr('whoami', 'Branch Identity')[1]
121
110
        self.assertEquals('"Branch Identity" does not seem to contain an '
122
111
                          'email address.  This is allowed, but not '
123
112
                          'recommended.\n', display)