/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 breezy/tests/test_mail_client.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
        # The temporary filename is randomly generated, so it is not matched.
33
33
        self.assertEqual(['-a', 'file%', '-i'], commandline[:-1])
34
34
        commandline = mutt._get_compose_commandline('jrandom@example.org',
35
 
                                                     'Hi there!', None)
 
35
                                                    'Hi there!', None)
36
36
        self.assertEqual(['-s', 'Hi there!', '--', 'jrandom@example.org'],
37
37
                         commandline)
38
38
 
39
39
    def test_commandline_is_8bit(self):
40
40
        mutt = mail_client.Mutt(None)
41
41
        cmdline = mutt._get_compose_commandline(u'jrandom@example.org',
42
 
            u'Hi there!', u'file%')
 
42
                                                u'Hi there!', u'file%')
43
43
        self.assertEqual(
44
44
            ['-s', 'Hi there!', '-a', 'file%', '--', 'jrandom@example.org'],
45
45
            cmdline)
46
46
        for item in cmdline:
47
47
            self.assertTrue(isinstance(item, str),
48
 
                'Command-line item %r is not a native string!' % item)
 
48
                            'Command-line item %r is not a native string!' % item)
49
49
 
50
50
 
51
51
class TestThunderbird(tests.TestCase):
62
62
        self.assertEqual(['-compose', "body=bo%27dy,"
63
63
                                      "subject='Hi there!',"
64
64
                                      "to='jrandom@example.org'"],
65
 
                                      commandline)
 
65
                         commandline)
66
66
 
67
67
    def test_commandline_is_8bit(self):
68
68
        # test for bug #139318
69
69
        tbird = mail_client.Thunderbird(None)
70
70
        cmdline = tbird._get_compose_commandline(u'jrandom@example.org',
71
 
            u'Hi there!', u'file%')
 
71
                                                 u'Hi there!', u'file%')
72
72
        self.assertEqual(['-compose',
73
 
            ("attachment='%s'," % urlutils.local_path_to_url('file%')) +
74
 
            "subject='Hi there!',to='jrandom@example.org'",
75
 
            ], cmdline)
 
73
                          ("attachment='%s'," %
 
74
                           urlutils.local_path_to_url('file%'))
 
75
                          + "subject='Hi there!',to='jrandom@example.org'",
 
76
                          ], cmdline)
76
77
        for item in cmdline:
77
78
            self.assertTrue(isinstance(item, str),
78
 
                'Command-line item %r is not a native string!' % item)
 
79
                            'Command-line item %r is not a native string!' % item)
79
80
 
80
81
 
81
82
class TestEmacsMail(tests.TestCase):
107
108
    def test_commandline_is_8bit(self):
108
109
        eclient = mail_client.EmacsMail(None)
109
110
        commandline = eclient._get_compose_commandline(u'jrandom@example.org',
110
 
            u'Hi there!', u'file%')
 
111
                                                       u'Hi there!', u'file%')
111
112
        if eclient.elisp_tmp_file is not None:
112
113
            self.addCleanup(osutils.delete_any, eclient.elisp_tmp_file)
113
114
        for item in commandline:
114
115
            self.assertTrue(isinstance(item, str),
115
 
                'Command-line item %r is not a native string!' % item)
 
116
                            'Command-line item %r is not a native string!' % item)
116
117
 
117
118
 
118
119
class TestXDGEmail(tests.TestCase):
134
135
    def test_commandline_is_8bit(self):
135
136
        xdg_email = mail_client.XDGEmail(None)
136
137
        cmdline = xdg_email._get_compose_commandline(u'jrandom@example.org',
137
 
            u'Hi there!', u'file%')
 
138
                                                     u'Hi there!', u'file%')
138
139
        self.assertEqual(
139
140
            ['jrandom@example.org', '--subject', 'Hi there!',
140
141
             '--attach', 'file%'],
141
142
            cmdline)
142
143
        for item in cmdline:
143
144
            self.assertTrue(isinstance(item, str),
144
 
                'Command-line item %r is not a native string!' % item)
 
145
                            'Command-line item %r is not a native string!' % item)
145
146
 
146
147
 
147
148
class TestEvolution(tests.TestCase):
158
159
    def test_commandline_is_8bit(self):
159
160
        evo = mail_client.Evolution(None)
160
161
        cmdline = evo._get_compose_commandline(u'jrandom@example.org',
161
 
            u'Hi there!', u'file%')
 
162
                                               u'Hi there!', u'file%')
162
163
        self.assertEqual(
163
164
            ['mailto:jrandom@example.org?attach=file%25&subject=Hi%20there%21'
164
 
            ],
 
165
             ],
165
166
            cmdline)
166
167
        for item in cmdline:
167
168
            self.assertTrue(isinstance(item, str),
168
 
                'Command-line item %r is not a native string!' % item)
 
169
                            'Command-line item %r is not a native string!' % item)
169
170
 
170
171
 
171
172
class TestKMail(tests.TestCase):
182
183
    def test_commandline_is_8bit(self):
183
184
        kmail = mail_client.KMail(None)
184
185
        cmdline = kmail._get_compose_commandline(u'jrandom@example.org',
185
 
            u'Hi there!', u'file%')
 
186
                                                 u'Hi there!', u'file%')
186
187
        self.assertEqual(
187
188
            ['-s', 'Hi there!', '--attach', 'file%', 'jrandom@example.org'],
188
189
            cmdline)
189
190
        for item in cmdline:
190
191
            self.assertTrue(isinstance(item, str),
191
 
                'Command-line item %r is not a native string!' % item)
 
192
                            'Command-line item %r is not a native string!' % item)
192
193
 
193
194
 
194
195
class TestClaws(tests.TestCase):
221
222
            cmdline)
222
223
        for item in cmdline:
223
224
            self.assertTrue(isinstance(item, str),
224
 
                'Command-line item %r is not a native string!' % item)
 
225
                            'Command-line item %r is not a native string!' % item)
225
226
 
226
227
    def test_with_from(self):
227
228
        claws = mail_client.Claws(None)
254
255
        """Prompt, to and subject are unicode, the attachement is binary"""
255
256
        editor = mail_client.Editor(None)
256
257
        prompt = editor._get_merge_prompt(u'foo\u1234',
257
 
                                        u'bar\u1234',
258
 
                                        u'baz\u1234',
259
 
                                        u'qux\u1234'.encode('utf-8'))
 
258
                                          u'bar\u1234',
 
259
                                          u'baz\u1234',
 
260
                                          u'qux\u1234'.encode('utf-8'))
260
261
        self.assertContainsRe(prompt, u'foo\u1234(.|\n)*bar\u1234'
261
262
                              u'(.|\n)*baz\u1234(.|\n)*qux\u1234')
262
263
        editor._get_merge_prompt(u'foo', u'bar', u'baz', b'qux\xff')