Commit 8c86f304 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Since r42905, _last_message, _previous_message and _message_list of

DummyMailHost are stored as class attributes rather than instance
attributes.

This behavior broke testPasswordTool and testCRM which instanciate
DummyMailHost and then check for _last_message.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43110 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 96d9c4e0
......@@ -33,7 +33,7 @@ import email.Header
import transaction
from Products.CMFCore.WorkflowCore import WorkflowException
from Products.ERP5Type.tests.utils import DummyMailHost, FileUpload
from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from Products.ERP5OOo.tests.testIngestion import FILENAME_REGULAR_EXPRESSION
......@@ -61,18 +61,10 @@ class BaseTestCRM(ERP5TypeTestCase):
def afterSetUp(self):
super(BaseTestCRM, self).afterSetUp()
# add a dummy mailhost not to send real messages
self.oldMailHost = getattr(self.portal, 'MailHost', None)
if self.oldMailHost is not None:
self.portal.manage_delObjects(['MailHost'])
self.portal._setObject('MailHost', DummyMailHost('MailHost'))
self.portal.MailHost.reset()
def beforeTearDown(self):
transaction.abort()
# restore the original MailHost
if self.oldMailHost is not None:
self.portal.manage_delObjects(['MailHost'])
self.portal._setObject('MailHost', DummyMailHost('MailHost'))
# clear modules if necessary
for module_name in clear_module_name_list:
module = self.portal.unrestrictedTraverse(module_name)
......
......@@ -34,7 +34,6 @@ from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.utils import DummyMailHost
from DateTime import DateTime
class TestPasswordTool(ERP5TypeTestCase):
......@@ -52,11 +51,8 @@ class TestPasswordTool(ERP5TypeTestCase):
def afterSetUp(self):
portal = self.getPortal()
if 'MailHost' in portal.objectIds():
portal.manage_delObjects(['MailHost'])
portal._setObject('MailHost', DummyMailHost('MailHost'))
portal.email_from_address = 'site@example.invalid'
self.portal.email_from_address = 'site@example.invalid'
self.portal.MailHost.reset()
self.portal.portal_caches.clearAllCache()
def beforeTearDown(self):
......@@ -70,7 +66,7 @@ class TestPasswordTool(ERP5TypeTestCase):
def getUserFolder(self):
"""Returns the acl_users. """
return self.getPortal().acl_users
return self.portal.acl_users
def _assertUserExists(self, login, password):
"""Checks that a user with login and password exists and can log in to the
......
......@@ -91,6 +91,12 @@ class DummyMailHostMixin(object):
""" Return last message """
return cls._last_message
@classmethod
def reset(cls):
cls._last_message = ()
cls._previous_message = ()
cls._message_list = []
class DummyMailHost(DummyMailHostMixin, MailHost):
pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment