[Zope3-checkins] CVS: Zope3/src/zope/app/mail/tests - .cvsignore:1.1 mail.zcml:1.1 test_directives.py:1.6

Stephan Richter srichter@cosmos.phy.tufts.edu
Sat, 2 Aug 2003 08:30:34 -0400


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

Modified Files:
	test_directives.py 
Added Files:
	.cvsignore mail.zcml 
Log Message:
Converted 'mail' ZCML namespace. tests and ftests pass.


=== Added File Zope3/src/zope/app/mail/tests/.cvsignore ===
mailbox



=== Added File Zope3/src/zope/app/mail/tests/mail.zcml ===
<configure xmlns="http://namespaces.zope.org/zope"
           xmlns:mail="http://namespaces.zope.org/mail">

  <include package="zope.app.mail" file="meta.zcml"/>

  <mail:queuedService 
      name="Mail"
      queuePath="./mailbox"
      mailer="test.smtp"
      permission="zope.Public" />
  
  <mail:directService 
      name="Mail2"
      mailer="test.mailer"
      permission="zope.Public" />

  <mail:sendmailMailer 
      id="Sendmail"
      command="/usr/lib/sendmail -oem -oi -f %(from)s %(to)s" />
  
  <mail:smtpMailer 
      id="smtp"
      hostname="localhost"
      port="25"
      username="zope3"
      password="xyzzy"/>
  
  <mail:smtpMailer 
      id="smtp2"
      hostname="smarthost"/>
 
</configure>


=== Zope3/src/zope/app/mail/tests/test_directives.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/mail/tests/test_directives.py:1.5	Mon Jul 28 18:20:27 2003
+++ Zope3/src/zope/app/mail/tests/test_directives.py	Sat Aug  2 08:30:28 2003
@@ -15,26 +15,18 @@
 
 $Id$
 """
+import os
 import unittest
 import threading
 
-from cStringIO import StringIO
-
+from zope.app.component.metaconfigure import managerHandler, provideInterface
+from zope.app.interfaces.mail import IMailService, ISMTPMailer, ISendmailMailer
+from zope.app.mail.metaconfigure import provideMailer, queryMailer
+from zope.app.mail import service
 from zope.component import getService
 from zope.component.tests.placelesssetup import PlacelessSetup
 from zope.configuration import xmlconfig
-
-from zope.app.component.metaconfigure import managerHandler, provideInterface
-import zope.app.mail
-import zope.app.interfaces.mail
-from zope.app.mail.metaconfigure import provideMailer
-
-template = """<zopeConfigure
-   xmlns='http://namespaces.zope.org/zope'
-   xmlns:mail='http://namespaces.zope.org/mail'>
-   xmlns:test='http://www.zope.org/NS/Zope3/test'>
-   %s
-   </zopeConfigure>"""
+import zope.app.mail.tests
 
 
 class MaildirStub:
@@ -50,86 +42,47 @@
         return None
 
 
-
 class DirectivesTest(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
         PlacelessSetup.setUp(self)
-        managerHandler('defineService', 'Mail',
-                       zope.app.interfaces.mail.IMailService)
-        provideInterface('zope.app.interfaces.mail.IMailService',
-                         zope.app.interfaces.mail.IMailService)
-        self.context = xmlconfig.file('meta.zcml', zope.app.mail)
-        from zope.app.mail import service
+        managerHandler('defineService', 'Mail', IMailService)
+        managerHandler('defineService', 'Mail2', IMailService)
+        provideInterface('zope.app.interfaces.mail.IMailService', IMailService)
+        provideMailer("test.smtp", object())
+        self.testMailer = object()
+        provideMailer('test.mailer', self.testMailer)
+        self.context = xmlconfig.file("mail.zcml", zope.app.mail.tests)
         self.orig_maildir = service.Maildir
         service.Maildir = MaildirStub
 
     def tearDown(self):
-        from zope.app.mail import service
         service.Maildir = self.orig_maildir
 
     def testQueuedService(self):
-        threads = threading.activeCount()
-        provideMailer("smtp", object())
-        xmlconfig.string(template % 
-            '''
-            <mail:queuedService name="Mail"
-               queuePath="/path/to/mailbox"
-               mailer="smtp"
-               permission="zope.Public" />
-            ''', self.context)         
         service = getService(None, 'Mail')
         self.assertEqual('QueuedMailService', service.__class__.__name__)
-        self.assertEqual('/path/to/mailbox', service.queuePath)
-        self.assertEqual(threading.activeCount(), threads + 1)
+        testdir = os.path.dirname(zope.app.mail.tests.__file__)
+        self.assertEqual(os.path.join(testdir, 'mailbox'),
+                         service.queuePath)
 
     def testDirectService(self):
-        testMailer = object()
-        provideMailer('test.mailer', testMailer)
-        xmlconfig.string(template % 
-            '''
-            <mail:directService name="Mail"
-               mailer="test.mailer"
-               permission="zope.Public" />
-            ''', self.context)
-        service = getService(None, 'Mail')
+        service = getService(None, 'Mail2')
         self.assertEqual('DirectMailService', service.__class__.__name__)
-        self.assert_(testMailer is service.mailer)
+        self.assert_(self.testMailer is service.mailer)
 
 
     def testSendmailMailer(self):
-        from zope.app.interfaces.mail import ISendmailMailer
-        from zope.app.mail.metaconfigure import queryMailer
-        xmlconfig.string(template % 
-            '''
-            <mail:sendmailMailer id="Sendmail"
-               command="/usr/lib/sendmail -oem -oi -f %(from)s %(to)s" />
-            ''', self.context)
         self.assert_(ISendmailMailer.isImplementedBy(queryMailer("Sendmail")))
 
     def testSMTPMailer(self):
-        from zope.app.interfaces.mail import ISMTPMailer
-        from zope.app.mail.metaconfigure import queryMailer
-        xmlconfig.string(template % (
-            '''
-            <mail:smtpMailer id="smtp"
-               hostname="localhost"
-               port="25"
-               username="zope3"
-               password="xyzzy"
-               />
-            '''), self.context)
-
-        xmlconfig.string(template % (
-            '''
-            <mail:smtpMailer id="smtp2"
-              hostname="smarthost"
-            />
-            '''), self.context)
         self.assert_(ISMTPMailer.isImplementedBy(queryMailer("smtp")))
 
+
 def test_suite():
-    return unittest.makeSuite(DirectivesTest)
+    return unittest.TestSuite((
+        unittest.makeSuite(DirectivesTest),
+        ))
 
 if __name__ == '__main__':
-    unittest.TextTestRunner().run(test_suite())
+    unittest.main()