[Zope3-checkins] CVS: Zope3/src/zope/app/mail/tests - test_directives.py:1.3.2.3 test_mailer.py:1.1.2.2

Albertas Agejevas alga@codeworks.lt
Mon, 23 Jun 2003 07:13:25 -0400


Update of /cvs-repository/Zope3/src/zope/app/mail/tests
In directory cvs.zope.org:/tmp/cvs-serv19503/src/zope/app/mail/tests

Modified Files:
      Tag: cw-mail-branch
	test_directives.py test_mailer.py 
Log Message:
Configuration related things:
  * fixed a bug where smtplib was fed a unicode string and barfed
  * renamed name attributes on mailer to id


=== Zope3/src/zope/app/mail/tests/test_directives.py 1.3.2.2 => 1.3.2.3 ===
--- Zope3/src/zope/app/mail/tests/test_directives.py:1.3.2.2	Mon May 26 14:25:49 2003
+++ Zope3/src/zope/app/mail/tests/test_directives.py	Mon Jun 23 07:13:24 2003
@@ -105,7 +105,7 @@
         from zope.app.mail.metaconfigure import queryMailer
         xmlconfig(StringIO(template % (
             '''
-            <mail:sendmailMailer name="Sendmail"
+            <mail:sendmailMailer id="Sendmail"
                command="/usr/lib/sendmail -oem -oi -f %(from)s %(to)s" />
             '''
             )), None, Context([], zope.app.mail))
@@ -116,7 +116,7 @@
         from zope.app.mail.metaconfigure import queryMailer
         xmlconfig(StringIO(template % (
             '''
-            <mail:smtpMailer name="smtp"
+            <mail:smtpMailer id="smtp"
                hostname="localhost"
                port="25"
                username="zope3"
@@ -127,7 +127,7 @@
 
         xmlconfig(StringIO(template % (
             '''
-            <mail:smtpMailer name="smtp2"
+            <mail:smtpMailer id="smtp2"
               hostname="smarthost"
             />
             '''


=== Zope3/src/zope/app/mail/tests/test_mailer.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/mail/tests/test_mailer.py:1.1.2.1	Thu May 22 14:09:03 2003
+++ Zope3/src/zope/app/mail/tests/test_mailer.py	Mon Jun 23 07:13:24 2003
@@ -53,15 +53,17 @@
 
 class TestSMTPMailer(unittest.TestCase):
 
-    def setUp(self):
+    def setUp(self, port=None):
         from zope.app.mail.mailer import SMTPMailer
 
-
         class SMTP:
 
             def __init__(myself, h, p):
                 myself.hostname = h
                 myself.port = p
+                if type(p) == type(u""):
+                    import socket
+                    raise socket.error("Int or String expected")
                 self.smtp = myself
 
             def sendmail(self, f, t, m):
@@ -76,21 +78,27 @@
             def quit(self):
                 self.quit = True
 
-        self.mailer = SMTPMailer()
+        if port is None:
+            self.mailer = SMTPMailer()
+        else:
+            self.mailer = SMTPMailer(u'localhost', port)
         self.mailer.smtp = SMTP
 
     def test_interface(self):
         verifyObject(ISMTPMailer, self.mailer)
 
     def test_send(self):
-        fromaddr = 'me@example.com'
-        toaddrs = ('you@example.com', 'him@example.com')
-        msgtext = 'Headers: headers\n\nbodybodybody\n-- \nsig\n'
-        self.mailer.send(fromaddr, toaddrs, msgtext)
-        self.assertEquals(self.smtp.fromaddr, fromaddr)
-        self.assertEquals(self.smtp.toaddrs, toaddrs)
-        self.assertEquals(self.smtp.msgtext, msgtext)
-        self.assert_(self.smtp.quit)
+        for run in (1,2):
+            if run == 2:
+                self.setUp(u'25')
+            fromaddr = 'me@example.com'
+            toaddrs = ('you@example.com', 'him@example.com')
+            msgtext = 'Headers: headers\n\nbodybodybody\n-- \nsig\n'
+            self.mailer.send(fromaddr, toaddrs, msgtext)
+            self.assertEquals(self.smtp.fromaddr, fromaddr)
+            self.assertEquals(self.smtp.toaddrs, toaddrs)
+            self.assertEquals(self.smtp.msgtext, msgtext)
+            self.assert_(self.smtp.quit)
 
     def test_send_auth(self):
         fromaddr = 'me@example.com'
@@ -104,11 +112,12 @@
         self.assertEquals(self.smtp.username, 'foo')
         self.assertEquals(self.smtp.password, 'evil')
         self.assertEquals(self.smtp.hostname, 'spamrelay')
-        self.assertEquals(self.smtp.port, 31337)
+        self.assertEquals(self.smtp.port, '31337')
         self.assertEquals(self.smtp.fromaddr, fromaddr)
         self.assertEquals(self.smtp.toaddrs, toaddrs)
         self.assertEquals(self.smtp.msgtext, msgtext)
         self.assert_(self.smtp.quit)
+
 
 
 def test_suite():