/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: Andrew Bennetts
  • Date: 2008-04-02 00:14:00 UTC
  • mfrom: (3324 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3756.
  • Revision ID: andrew.bennetts@canonical.com-20080402001400-r1pqse38i03dl97w
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
                'Command-line item %r is unicode!' % item)
72
72
 
73
73
 
 
74
class TestEmacsMailMode(tests.TestCase):
 
75
 
 
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)
 
82
 
 
83
        commandline = eclient._get_compose_commandline('jrandom@example.org',
 
84
                                                     'Hi there!', None)
 
85
        self.assertEqual(['--eval', '(mail nil "jrandom@example.org" "Hi there!")',
 
86
                          '(mail-text)', '(newline)'], commandline)
 
87
 
 
88
    def test_commandline_is_8bit(self):
 
89
        eclient = mail_client.EmacsMailMode(None)
 
90
        commandline = eclient._get_compose_commandline(u'jrandom@example.org',
 
91
            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
        for item in commandline:
 
96
            self.assertFalse(isinstance(item, unicode),
 
97
                'Command-line item %r is unicode!' % item)
 
98
 
 
99
 
74
100
class TestXDGEmail(tests.TestCase):
75
101
 
76
102
    def test_commandline(self):
159
185
        self.assertContainsRe(prompt, u'foo\u1234(.|\n)*bar\u1234'
160
186
                              u'(.|\n)*baz\u1234(.|\n)*qux\u1234')
161
187
        editor._get_merge_prompt(u'foo', u'bar', u'baz', 'qux\xff')
 
188
 
 
189
 
 
190
class DummyMailClient(object):
 
191
 
 
192
    def compose_merge_request(self, *args, **kwargs):
 
193
        self.args = args
 
194
        self.kwargs = kwargs
 
195
 
 
196
 
 
197
class DefaultMailDummyClient(mail_client.DefaultMail):
 
198
 
 
199
    def __init__(self):
 
200
        self.client = DummyMailClient()
 
201
 
 
202
    def _mail_client(self):
 
203
        return self.client
 
204
 
 
205
 
 
206
class TestDefaultMail(tests.TestCase):
 
207
 
 
208
    def test_compose_merge_request(self):
 
209
        client = DefaultMailDummyClient()
 
210
        to = "a@b.com"
 
211
        subject = "[MERGE]"
 
212
        directive = "directive",
 
213
        basename = "merge"
 
214
        client.compose_merge_request(to, subject, directive,
 
215
                                     basename=basename)
 
216
        dummy_client = client.client
 
217
        self.assertEqual(dummy_client.args, (to, subject, directive))
 
218
        self.assertEqual(dummy_client.kwargs, {"basename":basename})