1
# Copyright (C) 2006, 2007, 2009-2012 Canonical Ltd
1
# Copyright (C) 2006, 2007, 2009-2012, 2016 Canonical Ltd
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
31
31
def assertWhoAmI(self, expected, *cmd_args, **kwargs):
32
32
out, err = self.run_bzr(('whoami',) + cmd_args, **kwargs)
33
self.assertEquals('', err)
33
self.assertEqual('', err)
34
34
lines = out.splitlines()
35
35
self.assertLength(1, lines)
36
self.assertEquals(expected, lines[0].rstrip())
36
self.assertEqual(expected, lines[0].rstrip())
38
38
def test_whoami_no_args_no_conf(self):
39
39
# this should always identify something, if only "john@localhost"
40
40
out = self.run_bzr("whoami")[0]
41
41
self.assertTrue(len(out) > 0)
42
self.assertEquals(1, out.count('@'))
42
self.assertEqual(1, out.count('@'))
44
44
def test_whoami_email_no_args(self):
45
45
out = self.run_bzr("whoami --email")[0]
46
46
self.assertTrue(len(out) > 0)
47
self.assertEquals(1, out.count('@'))
47
self.assertEqual(1, out.count('@'))
49
49
def test_whoami_email_arg(self):
50
50
# whoami --email is mutually exclusive with any arguments
51
51
out = self.run_bzr("whoami --email 'foo <foo@example.com>'", 3)[0]
52
self.assertEquals("", out)
52
self.assertEqual("", out)
54
54
def set_branch_email(self, b, email):
55
55
b.get_config_stack().set('email', email)
93
93
"""verify that a warning is displayed if no email is given."""
94
94
self.make_branch_and_tree('.')
95
95
display = self.run_bzr(['whoami', 'Branch Identity'])[1]
96
self.assertEquals('"Branch Identity" does not seem to contain an '
96
self.assertEqual('"Branch Identity" does not seem to contain an '
97
97
'email address. This is allowed, but not '
98
98
'recommended.\n', display)
118
118
# Refresh wt as 'whoami' modified it
119
119
wt = wt.bzrdir.open_workingtree()
120
120
c = wt.branch.get_config_stack()
121
self.assertEquals('Changed Identity <changed@identi.ty>',
121
self.assertEqual('Changed Identity <changed@identi.ty>',
124
124
def test_whoami_remote_directory(self):
134
134
# The identity has been set in the branch config (but not the global
136
136
c = branch.Branch.open(url).get_config_stack()
137
self.assertEquals('Changed Identity <changed@identi.ty>',
137
self.assertEqual('Changed Identity <changed@identi.ty>',
139
139
# Ensuring that the value does not come from the bazaar.conf file
140
140
# itself requires some isolation setup