[Zope3-checkins] CVS: Zope3/src/zope/app/wiki/tests -
test_wikimail.py:1.6
Eckart Hertzler
eckart at hertzler.de
Mon May 10 09:36:46 EDT 2004
Update of /cvs-repository/Zope3/src/zope/app/wiki/tests
In directory cvs.zope.org:/tmp/cvs-serv7519/src/zope/app/wiki/tests
Modified Files:
test_wikimail.py
Log Message:
added a test for the change mail notification and sending
=== Zope3/src/zope/app/wiki/tests/test_wikimail.py 1.5 => 1.6 ===
--- 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 Mon May 10 09:36:45 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