~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_mail_client.py

  • Committer: Alexander Belchenko
  • Date: 2008-03-02 16:54:19 UTC
  • mto: This revision was merged to the branch mainline in revision 3267.
  • Revision ID: bialix@ukr.net-20080302165419-2u0r0ogn1h7s4gib
because every mail client has different rules to compose command line we should encode arguments to 8 bit string only when needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
        self.assertEqual(['-s', 'Hi there!', 'jrandom@example.org'],
33
33
                         commandline)
34
34
 
 
35
    def test_commandline_is_8bit(self):
 
36
        mutt = mail_client.Mutt(None)
 
37
        cmdline = mutt._get_compose_commandline(u'jrandom@example.org',
 
38
            u'Hi there!', u'file%')
 
39
        self.assertEqual(
 
40
            ['-s', 'Hi there!', '-a', 'file%', 'jrandom@example.org'],
 
41
            cmdline)
 
42
        for item in cmdline:
 
43
            self.assertFalse(isinstance(item, unicode),
 
44
                'Command-line item %r is unicode!' % item)
 
45
 
35
46
 
36
47
class TestThunderbird(tests.TestCase):
37
48
 
49
60
    def test_commandline_is_8bit(self):
50
61
        # test for bug #139318
51
62
        tbird = mail_client.Thunderbird(None)
52
 
        cmdline = tbird._get_compose_8bit_commandline('thunderbird',
53
 
            u'jrandom@example.org', u'Hi there!', u'file%')
54
 
        self.assertEqual(['thunderbird',
55
 
            '-compose',
 
63
        cmdline = tbird._get_compose_commandline(u'jrandom@example.org',
 
64
            u'Hi there!', u'file%')
 
65
        self.assertEqual(['-compose',
56
66
            ("attachment='%s'," % urlutils.local_path_to_url('file%')) +
57
67
            "subject='Hi there!',to='jrandom@example.org'",
58
68
            ], cmdline)
77
87
        self.assertEqual(['jrandom@example.org', '--subject', 'Hi there!'],
78
88
                         commandline)
79
89
 
 
90
    def test_commandline_is_8bit(self):
 
91
        xdg_email = mail_client.XDGEmail(None)
 
92
        cmdline = xdg_email._get_compose_commandline(u'jrandom@example.org',
 
93
            u'Hi there!', u'file%')
 
94
        self.assertEqual(
 
95
            ['jrandom@example.org', '--subject', 'Hi there!',
 
96
             '--attach', 'file%'],
 
97
            cmdline)
 
98
        for item in cmdline:
 
99
            self.assertFalse(isinstance(item, unicode),
 
100
                'Command-line item %r is unicode!' % item)
 
101
 
80
102
 
81
103
class TestEvolution(tests.TestCase):
82
104
 
89
111
        self.assertEqual(['mailto:jrandom@example.org?subject=Hi%20there%21'],
90
112
                         commandline)
91
113
 
 
114
    def test_commandline_is_8bit(self):
 
115
        evo = mail_client.Evolution(None)
 
116
        cmdline = evo._get_compose_commandline(u'jrandom@example.org',
 
117
            u'Hi there!', u'file%')
 
118
        self.assertEqual(
 
119
            ['mailto:jrandom@example.org?attach=file%25&subject=Hi%20there%21'
 
120
            ],
 
121
            cmdline)
 
122
        for item in cmdline:
 
123
            self.assertFalse(isinstance(item, unicode),
 
124
                'Command-line item %r is unicode!' % item)
 
125
 
92
126
 
93
127
class TestKMail(tests.TestCase):
94
128
 
101
135
        self.assertEqual(['-s', 'Hi there!', 'jrandom@example.org'],
102
136
                         commandline)
103
137
 
 
138
    def test_commandline_is_8bit(self):
 
139
        kmail = mail_client.KMail(None)
 
140
        cmdline = kmail._get_compose_commandline(u'jrandom@example.org',
 
141
            u'Hi there!', u'file%')
 
142
        self.assertEqual(
 
143
            ['-s', 'Hi there!', '--attach', 'file%', 'jrandom@example.org'],
 
144
            cmdline)
 
145
        for item in cmdline:
 
146
            self.assertFalse(isinstance(item, unicode),
 
147
                'Command-line item %r is unicode!' % item)
 
148
 
104
149
 
105
150
class TestEditor(tests.TestCase):
106
151