[Zope-Checkins] SVN: Zope/branches/2.10/ Merged r69799:69800 from
2.9 branch.
Stefan H. Holek
stefan at epy.co.at
Sun Aug 27 12:05:39 EDT 2006
Log message for revision 69801:
Merged r69799:69800 from 2.9 branch.
Fixed MailHost documentation; simple_send does not
process or validate its arguments in any way.
Resolves http://www.zope.org/Collectors/Zope/2152
Changed:
U Zope/branches/2.10/doc/CHANGES.txt
U Zope/branches/2.10/lib/python/Products/MailHost/help/Mail-Host.stx
U Zope/branches/2.10/lib/python/Products/MailHost/help/MailHost.py
U Zope/branches/2.10/lib/python/Products/MailHost/tests/testMailHost.py
-=-
Modified: Zope/branches/2.10/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.10/doc/CHANGES.txt 2006-08-27 16:01:41 UTC (rev 69800)
+++ Zope/branches/2.10/doc/CHANGES.txt 2006-08-27 16:05:36 UTC (rev 69801)
@@ -8,10 +8,13 @@
Bugs fixed
- - Collector #2176: Fixed bad logging call.
+ - Collector #2152: Fixed MailHost documentation; simple_send does not
+ process or validate its arguments in any way.
- Collector #2175: ZTUtils.make_hidden_input did not escape double-quotes.
+ - Collector #2176: Fixed bad logging call.
+
- Collector #1907: Moved 'alt' property from File to Image.
- Collector #1983: Specifying session-resolution-seconds >= 1200 caused
Modified: Zope/branches/2.10/lib/python/Products/MailHost/help/Mail-Host.stx
===================================================================
--- Zope/branches/2.10/lib/python/Products/MailHost/help/Mail-Host.stx 2006-08-27 16:01:41 UTC (rev 69800)
+++ Zope/branches/2.10/lib/python/Products/MailHost/help/Mail-Host.stx 2006-08-27 16:05:36 UTC (rev 69801)
@@ -10,7 +10,7 @@
Sends an email message where the messageText is an rfc822 formatted
message. This allows you complete control over the message headers,
- including setting any extra headers such as Cc: and Bcc:.
+ including setting any extra headers such as Cc: and Reply-To:.
The arguments are:
messageText -- The mail message. It can either be a rfc822
@@ -31,9 +31,11 @@
'simple_send(self, mto, mfrom, subject, body)'
Sends a message. Only To:, From: and Subject: headers can be set.
+ Note that simple_send does not process or validate its arguments
+ in any way.
The arguments are:
- mto -- A commaseparated string or list of recipient(s) of the message.
+ mto -- A commaseparated string of recipient(s) of the message.
mfrom -- The address of the message sender.
Modified: Zope/branches/2.10/lib/python/Products/MailHost/help/MailHost.py
===================================================================
--- Zope/branches/2.10/lib/python/Products/MailHost/help/MailHost.py 2006-08-27 16:01:41 UTC (rev 69800)
+++ Zope/branches/2.10/lib/python/Products/MailHost/help/MailHost.py 2006-08-27 16:05:36 UTC (rev 69801)
@@ -37,7 +37,7 @@
"""
Sends an email message where the messageText is an rfc822 formatted
message. This allows you complete control over the message headers,
- including setting any extra headers such as Cc: and Bcc:.
+ including setting any extra headers such as Cc: and Reply-To:.
The arguments are:
messageText -- The mail message. It can either be a rfc822
@@ -60,9 +60,11 @@
def simple_send(self, mto, mfrom, subject, body):
"""
Sends a message. Only To:, From: and Subject: headers can be set.
+ Note that simple_send does not process or validate its arguments
+ in any way.
The arguments are:
- mto -- A commaseparated string or list of recipient(s) of the message.
+ mto -- A commaseparated string of recipient(s) of the message.
mfrom -- The address of the message sender.
Modified: Zope/branches/2.10/lib/python/Products/MailHost/tests/testMailHost.py
===================================================================
--- Zope/branches/2.10/lib/python/Products/MailHost/tests/testMailHost.py 2006-08-27 16:01:41 UTC (rev 69800)
+++ Zope/branches/2.10/lib/python/Products/MailHost/tests/testMailHost.py 2006-08-27 16:05:36 UTC (rev 69801)
@@ -17,15 +17,26 @@
import unittest
+from Products.MailHost.MailHost import MailHost
from Products.MailHost.MailHost import MailHostError, _mungeHeaders
+class DummyMailHost(MailHost):
+ meta_type = 'Dummy Mail Host'
+ def __init__(self, id):
+ self.id = id
+ self.sent = ''
+ def _send(self, mfrom, mto, messageText):
+ self.sent = messageText
+
+
class TestMailHost(unittest.TestCase):
def _getTargetClass(self):
- from Products.MailHost.MailHost import MailHost
+ return DummyMailHost
- return MailHost
+ def _makeOne(self, *args, **kw):
+ return self._getTargetClass()(*args, **kw)
def test_z3interfaces(self):
from Products.MailHost.interfaces import IMailHost
@@ -113,7 +124,74 @@
'"Foo Bar" <foo at domain.com>'])
self.failUnless(resfrom == 'sender at domain.com' )
+ def testSendMessageOnly(self):
+ msg = """\
+To: "Name, Nick" <recipient at domain.com>, "Foo Bar" <foo at domain.com>
+From: sender at domain.com
+Subject: This is the subject
+Date: Sun, 27 Aug 2006 17:00:00 +0200
+This is the message body."""
+
+ mailhost = self._makeOne('MailHost')
+ mailhost.send(msg)
+ self.assertEqual(mailhost.sent, msg)
+
+ def testSendWithArguments(self):
+ inmsg = """\
+Date: Sun, 27 Aug 2006 17:00:00 +0200
+
+This is the message body."""
+
+ outmsg = """\
+Date: Sun, 27 Aug 2006 17:00:00 +0200
+Subject: This is the subject
+To: "Name, Nick" <recipient at domain.com>,"Foo Bar" <foo at domain.com>
+From: sender at domain.com
+
+This is the message body."""
+
+ mailhost = self._makeOne('MailHost')
+ mailhost.send(messageText=inmsg,
+ mto='"Name, Nick" <recipient at domain.com>, "Foo Bar" <foo at domain.com>',
+ mfrom='sender at domain.com', subject='This is the subject')
+ self.assertEqual(mailhost.sent, outmsg)
+
+ def testSendWithMtoList(self):
+ inmsg = """\
+Date: Sun, 27 Aug 2006 17:00:00 +0200
+
+This is the message body."""
+
+ outmsg = """\
+Date: Sun, 27 Aug 2006 17:00:00 +0200
+Subject: This is the subject
+To: "Name, Nick" <recipient at domain.com>,"Foo Bar" <foo at domain.com>
+From: sender at domain.com
+
+This is the message body."""
+
+ mailhost = self._makeOne('MailHost')
+ mailhost.send(messageText=inmsg,
+ mto=['"Name, Nick" <recipient at domain.com>', '"Foo Bar" <foo at domain.com>'],
+ mfrom='sender at domain.com', subject='This is the subject')
+ self.assertEqual(mailhost.sent, outmsg)
+
+ def testSimpleSend(self):
+ outmsg = """\
+From: sender at domain.com
+To: "Name, Nick" <recipient at domain.com>, "Foo Bar" <foo at domain.com>
+Subject: This is the subject
+
+This is the message body."""
+
+ mailhost = self._makeOne('MailHost')
+ mailhost.simple_send(mto='"Name, Nick" <recipient at domain.com>, "Foo Bar" <foo at domain.com>',
+ mfrom='sender at domain.com', subject='This is the subject',
+ body='This is the message body.')
+ self.assertEqual(mailhost.sent, outmsg)
+
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite( TestMailHost ) )
More information about the Zope-Checkins
mailing list