diff --git a/product/ERP5Type/tests/utils.py b/product/ERP5Type/tests/utils.py index 13fab30603e7837ff49b507fce22b8cedab160d6..f033edaf084a659c31bfc5a76449c032de817cb0 100644 --- a/product/ERP5Type/tests/utils.py +++ b/product/ERP5Type/tests/utils.py @@ -26,9 +26,25 @@ # ############################################################################## -"""Utility functions for unit testing +"""Utility functions and classes for unit testing """ +from Products.MailHost.MailHost import MailHost + +class DummyMailHost(MailHost): + """Dummy Mail Host that doesn't really send messages and keep a copy in + _last_message attrbute. + To use it, you have to replace existing mailhost in afterSetUp: + + if 'MailHost' in portal.objectIds(): + portal.manage_delObjects(['MailHost']) + portal._setObject('MailHost', DummyMailHost('MailHost')) + """ + _last_message = () + def _send( self, mfrom, mto, messageText ): + """Record message in _last_message.""" + self._last_message = (mfrom, mto, messageText) + def createZODBPythonScript(container, script_id, script_params, script_content): """Creates a Python script `script_id` in the given `container`, with