1
# Copyright (c) 2008 Twisted Matrix Laboratories.
2
# See LICENSE for details.
5
Tests for L{twisted.mail.scripts.mailmail}, the implementation of the
6
command line program I{mailmail}.
10
from StringIO import StringIO
12
from twisted.trial.unittest import TestCase
13
from twisted.mail.scripts.mailmail import parseOptions
16
class OptionsTests(TestCase):
18
Tests for L{parseOptions} which parses command line arguments and reads
19
message text from stdin to produce an L{Options} instance which can be
20
used to send a message.
22
def test_unspecifiedRecipients(self):
24
If no recipients are given in the argument list and there is no
25
recipient header in the message text, L{parseOptions} raises
26
L{SystemExit} with a string describing the problem.
28
self.addCleanup(setattr, sys, 'stdin', sys.stdin)
33
exc = self.assertRaises(SystemExit, parseOptions, [])
34
self.assertEqual(exc.args, ('No recipients specified.',))
37
def test_listQueueInformation(self):
39
The I{-bp} option for listing queue information is unsupported and
40
if it is passed to L{parseOptions}, L{SystemExit} is raised.
42
exc = self.assertRaises(SystemExit, parseOptions, ['-bp'])
43
self.assertEqual(exc.args, ("Unsupported option.",))
46
def test_stdioTransport(self):
48
The I{-bs} option for using stdin and stdout as the SMTP transport
49
is unsupported and if it is passed to L{parseOptions}, L{SystemExit}
52
exc = self.assertRaises(SystemExit, parseOptions, ['-bs'])
53
self.assertEqual(exc.args, ("Unsupported option.",))
56
def test_ignoreFullStop(self):
58
The I{-i} and I{-oi} options for ignoring C{"."} by itself on a line
59
are unsupported and if either is passed to L{parseOptions},
60
L{SystemExit} is raised.
62
exc = self.assertRaises(SystemExit, parseOptions, ['-i'])
63
self.assertEqual(exc.args, ("Unsupported option.",))
64
exc = self.assertRaises(SystemExit, parseOptions, ['-oi'])
65
self.assertEqual(exc.args, ("Unsupported option.",))
68
def test_copyAliasedSender(self):
70
The I{-om} option for copying the sender if they appear in an alias
71
expansion is unsupported and if it is passed to L{parseOptions},
72
L{SystemExit} is raised.
74
exc = self.assertRaises(SystemExit, parseOptions, ['-om'])
75
self.assertEqual(exc.args, ("Unsupported option.",))