32
31
self.assertEqual(['-s', 'Hi there!', 'jrandom@example.org'],
35
def test_commandline_is_8bit(self):
36
mutt = mail_client.Mutt(None)
37
cmdline = mutt._get_compose_commandline(u'jrandom@example.org',
38
u'Hi there!', u'file%')
40
['-s', 'Hi there!', '-a', 'file%', 'jrandom@example.org'],
43
self.assertFalse(isinstance(item, unicode),
44
'Command-line item %r is unicode!' % item)
47
35
class TestThunderbird(tests.TestCase):
57
45
self.assertEqual(['-compose', "subject='Hi there!',"
58
46
"to='jrandom@example.org'"], commandline)
60
def test_commandline_is_8bit(self):
61
# test for bug #139318
62
tbird = mail_client.Thunderbird(None)
63
cmdline = tbird._get_compose_commandline(u'jrandom@example.org',
64
u'Hi there!', u'file%')
65
self.assertEqual(['-compose',
66
("attachment='%s'," % urlutils.local_path_to_url('file%')) +
67
"subject='Hi there!',to='jrandom@example.org'",
70
self.assertFalse(isinstance(item, unicode),
71
'Command-line item %r is unicode!' % item)
74
class TestEmacsMail(tests.TestCase):
76
def test_commandline(self):
77
eclient = mail_client.EmacsMail(None)
79
commandline = eclient._get_compose_commandline(None, 'Hi there!', None)
80
self.assertEqual(['--eval', '(compose-mail nil "Hi there!")'],
83
commandline = eclient._get_compose_commandline('jrandom@example.org',
85
self.assertEqual(['--eval',
86
'(compose-mail "jrandom@example.org" "Hi there!")'],
89
# We won't be able to know the temporary file name at this stage
90
# so we can't raise an assertion with assertEqual
91
cmdline = eclient._get_compose_commandline(None, None, 'file%')
92
commandline = ' '.join(cmdline)
93
self.assertContainsRe(commandline, '--eval')
94
self.assertContainsRe(commandline, '(compose-mail nil nil)')
95
self.assertContainsRe(commandline, '(load .*)')
96
self.assertContainsRe(commandline, '(bzr-add-mime-att \"file%\")')
98
def test_commandline_is_8bit(self):
99
eclient = mail_client.EmacsMail(None)
100
commandline = eclient._get_compose_commandline(u'jrandom@example.org',
101
u'Hi there!', u'file%')
102
for item in commandline:
103
self.assertFalse(isinstance(item, unicode),
104
'Command-line item %r is unicode!' % item)
107
49
class TestXDGEmail(tests.TestCase):
109
51
def test_commandline(self):
110
52
xdg_email = mail_client.XDGEmail(None)
111
self.assertRaises(errors.NoMailAddressSpecified,
112
xdg_email._get_compose_commandline,
114
commandline = xdg_email._get_compose_commandline(
115
'jrandom@example.org', None, 'file%')
116
self.assertEqual(['jrandom@example.org', '--attach', 'file%'],
53
commandline = xdg_email._get_compose_commandline(None, None,
55
self.assertEqual([None, '--attach', 'file%'], commandline)
118
56
commandline = xdg_email._get_compose_commandline(
119
57
'jrandom@example.org', 'Hi there!', None)
120
58
self.assertEqual(['jrandom@example.org', '--subject', 'Hi there!'],
123
def test_commandline_is_8bit(self):
124
xdg_email = mail_client.XDGEmail(None)
125
cmdline = xdg_email._get_compose_commandline(u'jrandom@example.org',
126
u'Hi there!', u'file%')
128
['jrandom@example.org', '--subject', 'Hi there!',
129
'--attach', 'file%'],
132
self.assertFalse(isinstance(item, unicode),
133
'Command-line item %r is unicode!' % item)
136
62
class TestEvolution(tests.TestCase):
168
82
self.assertEqual(['-s', 'Hi there!', 'jrandom@example.org'],
171
def test_commandline_is_8bit(self):
172
kmail = mail_client.KMail(None)
173
cmdline = kmail._get_compose_commandline(u'jrandom@example.org',
174
u'Hi there!', u'file%')
176
['-s', 'Hi there!', '--attach', 'file%', 'jrandom@example.org'],
179
self.assertFalse(isinstance(item, unicode),
180
'Command-line item %r is unicode!' % item)
183
86
class TestEditor(tests.TestCase):
192
95
self.assertContainsRe(prompt, u'foo\u1234(.|\n)*bar\u1234'
193
96
u'(.|\n)*baz\u1234(.|\n)*qux\u1234')
194
97
editor._get_merge_prompt(u'foo', u'bar', u'baz', 'qux\xff')
197
class DummyMailClient(object):
199
def compose_merge_request(self, *args, **kwargs):
204
class DefaultMailDummyClient(mail_client.DefaultMail):
207
self.client = DummyMailClient()
209
def _mail_client(self):
213
class TestDefaultMail(tests.TestCase):
215
def test_compose_merge_request(self):
216
client = DefaultMailDummyClient()
219
directive = "directive",
221
client.compose_merge_request(to, subject, directive,
223
dummy_client = client.client
224
self.assertEqual(dummy_client.args, (to, subject, directive))
225
self.assertEqual(dummy_client.kwargs, {"basename":basename})