Log message for revision 69802:
  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/trunk/lib/python/Products/MailHost/help/Mail-Host.stx
  U   Zope/trunk/lib/python/Products/MailHost/help/MailHost.py
  U   Zope/trunk/lib/python/Products/MailHost/tests/testMailHost.py

-=-
Modified: Zope/trunk/lib/python/Products/MailHost/help/Mail-Host.stx
===================================================================
--- Zope/trunk/lib/python/Products/MailHost/help/Mail-Host.stx  2006-08-27 
16:05:36 UTC (rev 69801)
+++ Zope/trunk/lib/python/Products/MailHost/help/Mail-Host.stx  2006-08-27 
16:06:54 UTC (rev 69802)
@@ -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/trunk/lib/python/Products/MailHost/help/MailHost.py
===================================================================
--- Zope/trunk/lib/python/Products/MailHost/help/MailHost.py    2006-08-27 
16:05:36 UTC (rev 69801)
+++ Zope/trunk/lib/python/Products/MailHost/help/MailHost.py    2006-08-27 
16:06:54 UTC (rev 69802)
@@ -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/trunk/lib/python/Products/MailHost/tests/testMailHost.py
===================================================================
--- Zope/trunk/lib/python/Products/MailHost/tests/testMailHost.py       
2006-08-27 16:05:36 UTC (rev 69801)
+++ Zope/trunk/lib/python/Products/MailHost/tests/testMailHost.py       
2006-08-27 16:06:54 UTC (rev 69802)
@@ -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" <[EMAIL PROTECTED]>'])
         self.failUnless(resfrom == '[EMAIL PROTECTED]' )
 
+    def testSendMessageOnly(self):
+        msg = """\
+To: "Name, Nick" <[EMAIL PROTECTED]>, "Foo Bar" <[EMAIL PROTECTED]>
+From: [EMAIL PROTECTED]
+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" <[EMAIL PROTECTED]>,"Foo Bar" <[EMAIL PROTECTED]>
+From: [EMAIL PROTECTED]
+
+This is the message body."""
+
+        mailhost = self._makeOne('MailHost')
+        mailhost.send(messageText=inmsg,
+                      mto='"Name, Nick" <[EMAIL PROTECTED]>, "Foo Bar" <[EMAIL 
PROTECTED]>',
+                      mfrom='[EMAIL PROTECTED]', 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" <[EMAIL PROTECTED]>,"Foo Bar" <[EMAIL PROTECTED]>
+From: [EMAIL PROTECTED]
+
+This is the message body."""
+
+        mailhost = self._makeOne('MailHost')
+        mailhost.send(messageText=inmsg,
+                      mto=['"Name, Nick" <[EMAIL PROTECTED]>', '"Foo Bar" 
<[EMAIL PROTECTED]>'],
+                      mfrom='[EMAIL PROTECTED]', subject='This is the subject')
+        self.assertEqual(mailhost.sent, outmsg)
+
+    def testSimpleSend(self):
+        outmsg = """\
+From: [EMAIL PROTECTED]
+To: "Name, Nick" <[EMAIL PROTECTED]>, "Foo Bar" <[EMAIL PROTECTED]>
+Subject: This is the subject
+
+This is the message body."""
+
+        mailhost = self._makeOne('MailHost')
+        mailhost.simple_send(mto='"Name, Nick" <[EMAIL PROTECTED]>, "Foo Bar" 
<[EMAIL PROTECTED]>',
+                             mfrom='[EMAIL PROTECTED]', 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 ) )

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to