~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_mail_client.py

  • Committer: John Arbash Meinel
  • Date: 2009-03-27 22:29:55 UTC
  • mto: (3735.39.2 clean)
  • mto: This revision was merged to the branch mainline in revision 4280.
  • Revision ID: john@arbash-meinel.com-20090327222955-utifmfm888zerixt
Implement apply_delta_to_source which doesn't have to malloc another string.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
    def test_commandline(self):
30
30
        mutt = mail_client.Mutt(None)
31
 
        commandline = mutt._get_compose_commandline(
32
 
            None, None, 'file%', body="hello")
33
 
        # The temporary filename is randomly generated, so it is not matched.
34
 
        self.assertEqual(['-a', 'file%', '-i'], commandline[:-1])
 
31
        commandline = mutt._get_compose_commandline(None, None, 'file%')
 
32
        self.assertEqual(['-a', 'file%'], commandline)
35
33
        commandline = mutt._get_compose_commandline('jrandom@example.org',
36
34
                                                     'Hi there!', None)
37
 
        self.assertEqual(['-s', 'Hi there!', '--', 'jrandom@example.org'],
 
35
        self.assertEqual(['-s', 'Hi there!', 'jrandom@example.org'],
38
36
                         commandline)
39
37
 
40
38
    def test_commandline_is_8bit(self):
42
40
        cmdline = mutt._get_compose_commandline(u'jrandom@example.org',
43
41
            u'Hi there!', u'file%')
44
42
        self.assertEqual(
45
 
            ['-s', 'Hi there!', '-a', 'file%', '--', 'jrandom@example.org'],
 
43
            ['-s', 'Hi there!', '-a', 'file%', 'jrandom@example.org'],
46
44
            cmdline)
47
45
        for item in cmdline:
48
46
            self.assertFalse(isinstance(item, unicode),
97
95
        # We won't be able to know the temporary file name at this stage
98
96
        # so we can't raise an assertion with assertEqual
99
97
        cmdline = eclient._get_compose_commandline(None, None, 'file%')
100
 
        if eclient.elisp_tmp_file is not None:
101
 
            self.addCleanup(osutils.delete_any, eclient.elisp_tmp_file)
102
98
        commandline = ' '.join(cmdline)
103
99
        self.assertContainsRe(commandline, '--eval')
104
100
        self.assertContainsRe(commandline, '(compose-mail nil nil)')
109
105
        eclient = mail_client.EmacsMail(None)
110
106
        commandline = eclient._get_compose_commandline(u'jrandom@example.org',
111
107
            u'Hi there!', u'file%')
112
 
        if eclient.elisp_tmp_file is not None:
113
 
            self.addCleanup(osutils.delete_any, eclient.elisp_tmp_file)
114
108
        for item in commandline:
115
109
            self.assertFalse(isinstance(item, unicode),
116
110
                'Command-line item %r is unicode!' % item)
197
191
    def test_commandline(self):
198
192
        claws = mail_client.Claws(None)
199
193
        commandline = claws._get_compose_commandline(
200
 
            'jrandom@example.org', None, 'file%')
 
194
            None, None, 'file%')
201
195
        self.assertEqual(
202
 
            ['--compose', 'mailto:jrandom@example.org?', '--attach', 'file%'],
203
 
            commandline)
 
196
            ['--compose', 'mailto:?', '--attach', 'file%'], commandline)
204
197
        commandline = claws._get_compose_commandline(
205
198
            'jrandom@example.org', 'Hi there!', None)
206
199
        self.assertEqual(
224
217
            self.assertFalse(isinstance(item, unicode),
225
218
                'Command-line item %r is unicode!' % item)
226
219
 
227
 
    def test_with_from(self):
228
 
        claws = mail_client.Claws(None)
229
 
        cmdline = claws._get_compose_commandline(
230
 
            u'jrandom@example.org', None, None, None, u'qrandom@example.com')
231
 
        self.assertEqual(
232
 
            ['--compose',
233
 
             'mailto:jrandom@example.org?from=qrandom%40example.com'],
234
 
            cmdline)
235
 
 
236
 
    def test_to_required(self):
237
 
        claws = mail_client.Claws(None)
238
 
        self.assertRaises(errors.NoMailAddressSpecified,
239
 
                          claws._get_compose_commandline,
240
 
                          None, None, 'file%')
241
 
 
242
 
    def test_with_body(self):
243
 
        claws = mail_client.Claws(None)
244
 
        cmdline = claws._get_compose_commandline(
245
 
            u'jrandom@example.org', None, None, 'This is some body text')
246
 
        self.assertEqual(
247
 
            ['--compose',
248
 
             'mailto:jrandom@example.org?body=This%20is%20some%20body%20text'],
249
 
            cmdline)
250
 
 
251
220
 
252
221
class TestEditor(tests.TestCase):
253
222