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 ...@@ -33,7 +33,7 @@ import email.Header
import transaction import transaction
from Products.CMFCore.WorkflowCore import WorkflowException 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,\ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict _getConversionServerDict
from Products.ERP5OOo.tests.testIngestion import FILENAME_REGULAR_EXPRESSION from Products.ERP5OOo.tests.testIngestion import FILENAME_REGULAR_EXPRESSION
...@@ -61,18 +61,10 @@ class BaseTestCRM(ERP5TypeTestCase): ...@@ -61,18 +61,10 @@ class BaseTestCRM(ERP5TypeTestCase):
def afterSetUp(self): def afterSetUp(self):
super(BaseTestCRM, self).afterSetUp() super(BaseTestCRM, self).afterSetUp()
# add a dummy mailhost not to send real messages self.portal.MailHost.reset()
self.oldMailHost = getattr(self.portal, 'MailHost', None)
if self.oldMailHost is not None:
self.portal.manage_delObjects(['MailHost'])
self.portal._setObject('MailHost', DummyMailHost('MailHost'))
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() 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 # clear modules if necessary
for module_name in clear_module_name_list: for module_name in clear_module_name_list:
module = self.portal.unrestrictedTraverse(module_name) module = self.portal.unrestrictedTraverse(module_name)
......
...@@ -34,7 +34,6 @@ from Testing import ZopeTestCase ...@@ -34,7 +34,6 @@ from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.utils import DummyMailHost
from DateTime import DateTime from DateTime import DateTime
class TestPasswordTool(ERP5TypeTestCase): class TestPasswordTool(ERP5TypeTestCase):
...@@ -52,11 +51,8 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -52,11 +51,8 @@ class TestPasswordTool(ERP5TypeTestCase):
def afterSetUp(self): def afterSetUp(self):
portal = self.getPortal() self.portal.email_from_address = 'site@example.invalid'
if 'MailHost' in portal.objectIds(): self.portal.MailHost.reset()
portal.manage_delObjects(['MailHost'])
portal._setObject('MailHost', DummyMailHost('MailHost'))
portal.email_from_address = 'site@example.invalid'
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
def beforeTearDown(self): def beforeTearDown(self):
...@@ -70,7 +66,7 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -70,7 +66,7 @@ class TestPasswordTool(ERP5TypeTestCase):
def getUserFolder(self): def getUserFolder(self):
"""Returns the acl_users. """ """Returns the acl_users. """
return self.getPortal().acl_users return self.portal.acl_users
def _assertUserExists(self, login, password): def _assertUserExists(self, login, password):
"""Checks that a user with login and password exists and can log in to the """Checks that a user with login and password exists and can log in to the
......
...@@ -91,6 +91,12 @@ class DummyMailHostMixin(object): ...@@ -91,6 +91,12 @@ class DummyMailHostMixin(object):
""" Return last message """ """ Return last message """
return cls._last_message return cls._last_message
@classmethod
def reset(cls):
cls._last_message = ()
cls._previous_message = ()
cls._message_list = []
class DummyMailHost(DummyMailHostMixin, MailHost): class DummyMailHost(DummyMailHostMixin, MailHost):
pass 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