[Zope3-checkins] CVS: Zope3/src/zope/app/wiki/tests - test_wikimail.py:1.5.8.1

Martijn Faassen m.faassen at vet.uu.nl
Tue May 11 05:11:02 EDT 2004


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

Modified Files:
      Tag: faassen-interfaces-branch
	test_wikimail.py 
Log Message:
Sync up with changes in HEAD (so I can generate up to date patch file).


=== Zope3/src/zope/app/wiki/tests/test_wikimail.py 1.5 => 1.5.8.1 ===
--- Zope3/src/zope/app/wiki/tests/test_wikimail.py:1.5	Sat Mar 13 18:01:15 2004
+++ Zope3/src/zope/app/wiki/tests/test_wikimail.py	Tue May 11 05:10:31 2004
@@ -17,13 +17,15 @@
 """
 import unittest
 
-from zope.interface import classImplements 
+from zope.interface import classImplements, implements 
 from zope.app.tests import ztapi
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.app.site.tests.placefulsetup import PlacefulSetup
 from zope.app.annotation.interfaces import IAnnotations, IAttributeAnnotatable
 from zope.app.event.interfaces import ISubscriber
+from zope.app.event.objectevent import ObjectModifiedEvent
 from zope.app.annotation.attribute import AttributeAnnotations
+from zope.app.mail.interfaces import IMailDelivery
 
 from zope.app.wiki.interfaces import IWikiPage, IWiki, IMailSubscriptions
 from zope.app.wiki.wikipage import WikiPage
@@ -32,6 +34,7 @@
 
 SubscriberKey = 'http://www.zope.org/zwiki#1.0/MailSubscriptions/emails'
 
+mail_result=[]
 
 class MailSubscriptionTest(PlacelessSetup):
 
@@ -95,6 +98,15 @@
         return Wiki()
 
 
+
+class MailDeliveryStub(object):
+  
+    implements(IMailDelivery)
+
+    def send(self, fromaddr, toaddrs, message):
+        mail_result.append((fromaddr, toaddrs, message))
+
+
 class WikiMailerTest(PlacefulSetup, unittest.TestCase):
 
     # Note: There are several other methods in this class, but they require
@@ -113,6 +125,9 @@
                        MailSubscriptions)
         ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations,
                        AttributeAnnotations)
+        delivery = MailDeliveryStub()
+        ztapi.provideUtility(IMailDelivery, delivery,
+                             name='wiki-delivery')
 
     def test_Interface(self):
         self.failUnless(ISubscriber.providedBy(mailer))
@@ -129,6 +144,25 @@
         page = wiki['page1']
         self.assertEqual(('blah at bar.com', 'foo at bar.com'),
                          mailer.getAllSubscribers(page))
+
+    def test_notify(self):
+        wiki = Wiki()
+        wiki_sub = MailSubscriptions(wiki)
+        wiki_sub.context.__annotations__[SubscriberKey] = ('foo at bar.com',)
+        page = WikiPage()
+        page_sub = MailSubscriptions(page)
+        page_sub.context.__annotations__[SubscriberKey] = ('blah at bar.com',)
+        wiki['page1'] = page
+        page.source = 'Hello World!'
+        event = ObjectModifiedEvent(page)
+        mailer.notify(event)
+        self.assertEqual('wiki at zope3.org', 
+                         mail_result[0][0])
+        self.assertEqual(('blah at bar.com', 'foo at bar.com'), mail_result[0][1])
+        self.assertEqual('Subject: Modified: page1\n\n\nHello World!',
+                         mail_result[0][2])
+  
+
 
 def test_suite():
     return unittest.TestSuite((




More information about the Zope3-Checkins mailing list