~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-07-12 21:53:00 UTC
  • mfrom: (1840.1.5 bzr.dev.whoami)
  • Revision ID: pqm@pqm.ubuntu.com-20060712215300-126aea223e34b65c
(robey) 'bzr whoami address' gives a warning if missing email address

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
        """branch specific user identity works."""
41
41
        wt = self.make_branch_and_tree('.')
42
42
        b = bzrlib.branch.Branch.open('.')
43
 
        b.get_config().set_user_option('email', 'Branch Identity <branch@identi.ty>')
 
43
        b.get_config().set_user_option('email',
 
44
                                       'Branch Identity <branch@identi.ty>')
44
45
        bzr_email = os.environ.get('BZREMAIL')
45
46
        if bzr_email is not None:
46
47
            del os.environ['BZREMAIL']
64
65
    def test_whoami_utf8(self):
65
66
        """verify that an identity can be in utf-8."""
66
67
        wt = self.make_branch_and_tree('.')
67
 
        self.run_bzr('whoami', u'Branch Identity \u20ac <branch@identi.ty>', encoding='utf-8')
 
68
        self.run_bzr('whoami', u'Branch Identity \u20ac <branch@identi.ty>',
 
69
                     encoding='utf-8')
68
70
        bzr_email = os.environ.get('BZREMAIL')
69
71
        if bzr_email is not None:
70
72
            del os.environ['BZREMAIL']
71
73
        try:
72
74
            whoami = self.run_bzr("whoami", encoding='utf-8')[0]
73
 
            self.assertEquals('Branch Identity \xe2\x82\xac <branch@identi.ty>\n', whoami)
74
 
            whoami_email = self.run_bzr("whoami", "--email", encoding='utf-8')[0]
 
75
            self.assertEquals('Branch Identity \xe2\x82\xac ' +
 
76
                              '<branch@identi.ty>\n', whoami)
 
77
            whoami_email = self.run_bzr("whoami", "--email",
 
78
                                        encoding='utf-8')[0]
75
79
            self.assertEquals('branch@identi.ty\n', whoami_email)
76
80
        finally:
77
81
            if bzr_email is not None:
78
82
                os.environ['BZREMAIL'] = bzr_email
79
83
 
80
84
    def test_whoami_ascii(self):
81
 
        """verify that whoami doesn't totally break when in utf-8, using an ascii encoding."""
 
85
        """
 
86
        verify that whoami doesn't totally break when in utf-8, using an ascii
 
87
        encoding.
 
88
        """
82
89
        wt = self.make_branch_and_tree('.')
83
90
        b = bzrlib.branch.Branch.open('.')
84
 
        b.get_config().set_user_option('email', u'Branch Identity \u20ac <branch@identi.ty>')
 
91
        b.get_config().set_user_option('email', u'Branch Identity \u20ac ' +
 
92
                                       '<branch@identi.ty>')
85
93
        bzr_email = os.environ.get('BZREMAIL')
86
94
        if bzr_email is not None:
87
95
            del os.environ['BZREMAIL']
88
96
        try:
89
97
            whoami = self.run_bzr("whoami", encoding='ascii')[0]
90
98
            self.assertEquals('Branch Identity ? <branch@identi.ty>\n', whoami)
91
 
            whoami_email = self.run_bzr("whoami", "--email", encoding='ascii')[0]
 
99
            whoami_email = self.run_bzr("whoami", "--email",
 
100
                                        encoding='ascii')[0]
92
101
            self.assertEquals('branch@identi.ty\n', whoami_email)
93
102
        finally:
94
103
            if bzr_email is not None:
95
104
                os.environ['BZREMAIL'] = bzr_email
 
105
 
 
106
    def test_warning(self):
 
107
        """verify that a warning is displayed if no email is given."""
 
108
        self.make_branch_and_tree('.')
 
109
        display = self.run_bzr('whoami', 'Branch Identity')[1]
 
110
        self.assertEquals('"Branch Identity" does not seem to contain an '
 
111
                          'email address.  This is allowed, but not '
 
112
                          'recommended.\n', display)