13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
from bzrlib import (
25
24
class TestMutt(tests.TestCase):
27
26
def test_commandline(self):
28
27
mutt = mail_client.Mutt(None)
29
commandline = mutt._get_compose_commandline(
30
None, None, 'file%', body="hello")
31
# The temporary filename is randomly generated, so it is not matched.
32
self.assertEqual(['-a', 'file%', '-i'], commandline[:-1])
28
commandline = mutt._get_compose_commandline(None, None, 'file%')
29
self.assertEqual(['-a', 'file%'], commandline)
33
30
commandline = mutt._get_compose_commandline('jrandom@example.org',
35
self.assertEqual(['-s', 'Hi there!', '--', 'jrandom@example.org'],
32
self.assertEqual(['-s', 'Hi there!', 'jrandom@example.org'],
38
35
def test_commandline_is_8bit(self):
40
37
cmdline = mutt._get_compose_commandline(u'jrandom@example.org',
41
38
u'Hi there!', u'file%')
43
['-s', 'Hi there!', '-a', 'file%', '--', 'jrandom@example.org'],
40
['-s', 'Hi there!', '-a', 'file%', 'jrandom@example.org'],
45
42
for item in cmdline:
46
43
self.assertFalse(isinstance(item, unicode),
56
53
self.assertEqual(['-compose', "attachment='%s'" %
57
54
urlutils.local_path_to_url('file%')], commandline)
58
55
commandline = tbird._get_compose_commandline('jrandom@example.org',
61
self.assertEqual(['-compose', "body=bo%27dy,"
62
"subject='Hi there!',"
63
"to='jrandom@example.org'"],
57
self.assertEqual(['-compose', "subject='Hi there!',"
58
"to='jrandom@example.org'"], commandline)
66
60
def test_commandline_is_8bit(self):
67
61
# test for bug #139318
95
89
# We won't be able to know the temporary file name at this stage
96
90
# so we can't raise an assertion with assertEqual
97
91
cmdline = eclient._get_compose_commandline(None, None, 'file%')
98
if eclient.elisp_tmp_file is not None:
99
self.addCleanup(osutils.delete_any, eclient.elisp_tmp_file)
100
92
commandline = ' '.join(cmdline)
101
93
self.assertContainsRe(commandline, '--eval')
102
94
self.assertContainsRe(commandline, '(compose-mail nil nil)')
107
99
eclient = mail_client.EmacsMail(None)
108
100
commandline = eclient._get_compose_commandline(u'jrandom@example.org',
109
101
u'Hi there!', u'file%')
110
if eclient.elisp_tmp_file is not None:
111
self.addCleanup(osutils.delete_any, eclient.elisp_tmp_file)
112
102
for item in commandline:
113
103
self.assertFalse(isinstance(item, unicode),
114
104
'Command-line item %r is unicode!' % item)
126
116
self.assertEqual(['jrandom@example.org', '--attach', 'file%'],
128
118
commandline = xdg_email._get_compose_commandline(
129
'jrandom@example.org', 'Hi there!', None, "bo'dy")
130
self.assertEqual(['jrandom@example.org', '--subject', 'Hi there!',
131
'--body', "bo'dy"], commandline)
119
'jrandom@example.org', 'Hi there!', None)
120
self.assertEqual(['jrandom@example.org', '--subject', 'Hi there!'],
133
123
def test_commandline_is_8bit(self):
134
124
xdg_email = mail_client.XDGEmail(None)
150
140
commandline = evo._get_compose_commandline(None, None, 'file%')
151
141
self.assertEqual(['mailto:?attach=file%25'], commandline)
152
142
commandline = evo._get_compose_commandline('jrandom@example.org',
153
'Hi there!', None, 'bo&dy')
154
self.assertEqual(['mailto:jrandom@example.org?body=bo%26dy&'
155
'subject=Hi%20there%21'], commandline)
144
self.assertEqual(['mailto:jrandom@example.org?subject=Hi%20there%21'],
157
147
def test_commandline_is_8bit(self):
158
148
evo = mail_client.Evolution(None)
190
180
'Command-line item %r is unicode!' % item)
193
class TestClaws(tests.TestCase):
195
def test_commandline(self):
196
claws = mail_client.Claws(None)
197
commandline = claws._get_compose_commandline(
198
'jrandom@example.org', None, 'file%')
200
['--compose', 'mailto:jrandom@example.org?', '--attach', 'file%'],
202
commandline = claws._get_compose_commandline(
203
'jrandom@example.org', 'Hi there!', None)
206
'mailto:jrandom@example.org?subject=Hi%20there%21'],
209
def test_commandline_is_8bit(self):
210
claws = mail_client.Claws(None)
211
cmdline = claws._get_compose_commandline(
212
u'jrandom@example.org', u'\xb5cosm of fun!', u'file%')
213
subject_string = urlutils.quote(
214
u'\xb5cosm of fun!'.encode(osutils.get_user_encoding(), 'replace'))
217
'mailto:jrandom@example.org?subject=%s' % subject_string,
222
self.assertFalse(isinstance(item, unicode),
223
'Command-line item %r is unicode!' % item)
225
def test_with_from(self):
226
claws = mail_client.Claws(None)
227
cmdline = claws._get_compose_commandline(
228
u'jrandom@example.org', None, None, None, u'qrandom@example.com')
231
'mailto:jrandom@example.org?from=qrandom%40example.com'],
234
def test_to_required(self):
235
claws = mail_client.Claws(None)
236
self.assertRaises(errors.NoMailAddressSpecified,
237
claws._get_compose_commandline,
240
def test_with_body(self):
241
claws = mail_client.Claws(None)
242
cmdline = claws._get_compose_commandline(
243
u'jrandom@example.org', None, None, 'This is some body text')
246
'mailto:jrandom@example.org?body=This%20is%20some%20body%20text'],
250
183
class TestEditor(tests.TestCase):
252
185
def test_get_merge_prompt_unicode(self):
289
222
basename=basename)
290
223
dummy_client = client.client
291
224
self.assertEqual(dummy_client.args, (to, subject, directive))
292
self.assertEqual(dummy_client.kwargs,
293
{"basename": basename, 'body': None})
225
self.assertEqual(dummy_client.kwargs, {"basename":basename})