products/CPSSubscriptions

changeset 1078:f4e7e5ad2d08

Fixed tests broken by fixing of site local utilities
author Georges Racinet on purity.racinet.fr <georges@racinet.fr>
date Sun, 23 Oct 2011 00:27:27 +0200
parents 6c7bb40a72c0
children aef7376ce342
files tests/testNotificationRules.py
diffstat 1 files changed, 13 insertions(+), 7 deletions(-) [+]
line diff
     1.1 --- a/tests/testNotificationRules.py
     1.2 +++ b/tests/testNotificationRules.py
     1.3 @@ -22,9 +22,13 @@
     1.4  import email
     1.5  import unittest
     1.6  
     1.7 +import transaction
     1.8 +from zope.interface import implements
     1.9 +from zope.app import zapi
    1.10 +
    1.11  from Acquisition import aq_parent, aq_inner
    1.12  from OFS.SimpleItem import SimpleItem
    1.13 -import transaction
    1.14 +from Products.MailHost.interfaces import IMailHost
    1.15  
    1.16  from Products.CPSSubscriptions.Notifications import NotificationRule
    1.17  
    1.18 @@ -36,6 +40,8 @@
    1.19      The list can then be inspected. This way you can see who got notified.
    1.20      """
    1.21  
    1.22 +    implements(IMailHost)
    1.23 +
    1.24      mail_log = []
    1.25  
    1.26      def clearLog(self):
    1.27 @@ -84,12 +90,12 @@
    1.28          self._stool.max_recipients_per_notification = 3
    1.29  
    1.30      def _setupDummyMailHost(self):
    1.31 -        # Set up the dummy mailhost
    1.32 -        self.portal._delObject('MailHost')
    1.33 -        self.portal._setObject('MailHost', DummyMailHost())
    1.34 -        self._mh = self.portal.MailHost
    1.35 -        # Get rid of any pending notifications
    1.36 -        transaction.commit()
    1.37 +        """Register the dummy mailhost instead of the standard one.
    1.38 +
    1.39 +        No need to clean this up in beforeTearDown
    1.40 +        """
    1.41 +        self._mh = DummyMailHost()
    1.42 +        zapi.getSiteManager().registerUtility(self._mh, IMailHost)
    1.43          self._mh.clearLog()
    1.44  
    1.45      def beforeTearDown(self):