/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: Xavier Maillard
  • Date: 2008-04-13 11:48:00 UTC
  • mto: (3364.1.1 bzr.ab.integration)
  • mto: This revision was merged to the branch mainline in revision 3365.
  • Revision ID: xma@gnu.org-20080413114800-b3tp394elic1793b
Replace mail-mode call with compose-mail from GNU Emacs.

This patch is a modified version of the current revno 3323.

It overloads it by:

1. defining a different python class EmacsMail "MUA agnostic".

   To use this option, just put these lines into ~/.bazaar/bazaar.conf
    
[DEFAULT]
mail_client = emacsclient

2. supporting any mail client of GNU Emacs family (mail-mode,
   message-mode, ...) The right tool will be called according to the
   value of the variable ``mail-user-agent``. So Virtually any Emacs
   mail client will work transparently if registered against
   ``mail-user-agent``.

3. adding a wrapper function around MIME attachment. This allow us not
   to have many different functions/classes to attach a file but one.

4. tests have been updated to follow the changes.

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):
 
74
class TestEmacsMail(tests.TestCase):
75
75
 
76
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)
 
77
        eclient = mail_client.EmacsMail(None)
 
78
 
 
79
        commandline = eclient._get_compose_commandline(None, 'Hi there!', None)
 
80
        self.assertEqual(['--eval', '(compose-mail nil "Hi there!")'],
 
81
                         commandline)
82
82
 
83
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)
 
84
                                                       'Hi there!', None)
 
85
        self.assertEqual(['--eval',
 
86
                          '(compose-mail "jrandom@example.org" "Hi there!")'],
 
87
                         commandline)
 
88
 
 
89
        # We won't be able to know the temporary file name at this stage
 
90
        # so we can't raise an assertion with assertEqual
 
91
        cmdline = eclient._get_compose_commandline(None, None, 'file%')
 
92
        commandline = ' '.join(cmdline)
 
93
        self.assertContainsRe(commandline, '--eval')
 
94
        self.assertContainsRe(commandline, '(compose-mail nil nil)')
 
95
        self.assertContainsRe(commandline, '(load .*)')
 
96
        self.assertContainsRe(commandline, '(bzr-add-mime-att \"file%\")')
87
97
 
88
98
    def test_commandline_is_8bit(self):
89
 
        eclient = mail_client.EmacsMailMode(None)
 
99
        eclient = mail_client.EmacsMail(None)
90
100
        commandline = eclient._get_compose_commandline(u'jrandom@example.org',
91
101
            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
102
        for item in commandline:
96
103
            self.assertFalse(isinstance(item, unicode),
97
104
                'Command-line item %r is unicode!' % item)