/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_mail_client.py

  • Committer: Michael Hudson
  • Date: 2009-02-26 22:28:08 UTC
  • mto: This revision was merged to the branch mainline in revision 4121.
  • Revision ID: michael.hudson@canonical.com-20090226222808-url1udsulbge2r28
_this_ works

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
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
16
16
 
17
17
import urllib
18
18
 
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),
58
56
        self.assertEqual(['-compose', "attachment='%s'" %
59
57
                          urlutils.local_path_to_url('file%')], commandline)
60
58
        commandline = tbird._get_compose_commandline('jrandom@example.org',
61
 
                                                     'Hi there!', None,
62
 
                                                     "bo'dy")
63
 
        self.assertEqual(['-compose', "body=bo%27dy,"
64
 
                                      "subject='Hi there!',"
65
 
                                      "to='jrandom@example.org'"],
66
 
                                      commandline)
 
59
                                                     'Hi there!', None)
 
60
        self.assertEqual(['-compose', "subject='Hi there!',"
 
61
                                      "to='jrandom@example.org'"], commandline)
67
62
 
68
63
    def test_commandline_is_8bit(self):
69
64
        # test for bug #139318
97
92
        # We won't be able to know the temporary file name at this stage
98
93
        # so we can't raise an assertion with assertEqual
99
94
        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
95
        commandline = ' '.join(cmdline)
103
96
        self.assertContainsRe(commandline, '--eval')
104
97
        self.assertContainsRe(commandline, '(compose-mail nil nil)')
109
102
        eclient = mail_client.EmacsMail(None)
110
103
        commandline = eclient._get_compose_commandline(u'jrandom@example.org',
111
104
            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
105
        for item in commandline:
115
106
            self.assertFalse(isinstance(item, unicode),
116
107
                'Command-line item %r is unicode!' % item)
128
119
        self.assertEqual(['jrandom@example.org', '--attach', 'file%'],
129
120
                         commandline)
130
121
        commandline = xdg_email._get_compose_commandline(
131
 
            'jrandom@example.org', 'Hi there!', None, "bo'dy")
132
 
        self.assertEqual(['jrandom@example.org', '--subject', 'Hi there!',
133
 
                          '--body', "bo'dy"], commandline)
 
122
            'jrandom@example.org', 'Hi there!', None)
 
123
        self.assertEqual(['jrandom@example.org', '--subject', 'Hi there!'],
 
124
                         commandline)
134
125
 
135
126
    def test_commandline_is_8bit(self):
136
127
        xdg_email = mail_client.XDGEmail(None)
152
143
        commandline = evo._get_compose_commandline(None, None, 'file%')
153
144
        self.assertEqual(['mailto:?attach=file%25'], commandline)
154
145
        commandline = evo._get_compose_commandline('jrandom@example.org',
155
 
                                                   'Hi there!', None, 'bo&dy')
156
 
        self.assertEqual(['mailto:jrandom@example.org?body=bo%26dy&'
157
 
                          'subject=Hi%20there%21'], commandline)
 
146
                                                   'Hi there!', None)
 
147
        self.assertEqual(['mailto:jrandom@example.org?subject=Hi%20there%21'],
 
148
                         commandline)
158
149
 
159
150
    def test_commandline_is_8bit(self):
160
151
        evo = mail_client.Evolution(None)
197
188
    def test_commandline(self):
198
189
        claws = mail_client.Claws(None)
199
190
        commandline = claws._get_compose_commandline(
200
 
            'jrandom@example.org', None, 'file%')
 
191
            None, None, 'file%')
201
192
        self.assertEqual(
202
 
            ['--compose', 'mailto:jrandom@example.org?', '--attach', 'file%'],
203
 
            commandline)
 
193
            ['--compose', 'mailto:?', '--attach', 'file%'], commandline)
204
194
        commandline = claws._get_compose_commandline(
205
195
            'jrandom@example.org', 'Hi there!', None)
206
196
        self.assertEqual(
224
214
            self.assertFalse(isinstance(item, unicode),
225
215
                'Command-line item %r is unicode!' % item)
226
216
 
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
217
 
252
218
class TestEditor(tests.TestCase):
253
219
 
291
257
                                     basename=basename)
292
258
        dummy_client = client.client
293
259
        self.assertEqual(dummy_client.args, (to, subject, directive))
294
 
        self.assertEqual(dummy_client.kwargs,
295
 
                         {"basename": basename, 'body': None})
 
260
        self.assertEqual(dummy_client.kwargs, {"basename":basename})