71
71
'Command-line item %r is unicode!' % item)
74
class TestEmacsMailMode(tests.TestCase):
74
class TestEmacsMail(tests.TestCase):
76
76
def test_commandline(self):
77
eclient = mail_client.EmacsMailMode(None)
78
commandline = eclient._get_compose_commandline(None, None, 'file%')
79
self.assertEqual(['--eval', '(mail nil nil nil)',
80
'(mail-text)', '(newline)',
81
'(attach "file%")'], commandline)
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
83
commandline = eclient._get_compose_commandline('jrandom@example.org',
85
self.assertEqual(['--eval', '(mail nil "jrandom@example.org" "Hi there!")',
86
'(mail-text)', '(newline)'], commandline)
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%\")')
88
98
def test_commandline_is_8bit(self):
89
eclient = mail_client.EmacsMailMode(None)
99
eclient = mail_client.EmacsMail(None)
90
100
commandline = eclient._get_compose_commandline(u'jrandom@example.org',
91
101
u'Hi there!', u'file%')
92
self.assertEqual(['--eval', '(mail nil "jrandom@example.org" "Hi there!")',
93
'(mail-text)', '(newline)',
94
'(attach "file%")'], commandline)
95
102
for item in commandline:
96
103
self.assertFalse(isinstance(item, unicode),
97
104
'Command-line item %r is unicode!' % item)