Skip to main content
Help us improve Python packaging – donate today!

Used for integration testing with Plone

Project Description

Introduction

collective.MockMailHost enables integration testing of email functionality from Plone. Simply add this egg to your [test] runner section, and install this product from PloneTestCase.

DO NOT USE THIS PRODUCT on your running Plone site. It replaces the standard MailHost with a Mock MailHost that you can poke at to check email content and recipients.

Has been tested with Plone 4 but should also work with earlier versions.

Using a member-posting forum

Test starting conversations, replying and modifying comments in a default member-posting forum.

First, some set-up:

>>> from Products.Five import zcml

Let us log all exceptions, which is useful for debugging. Also, clear portlet slots, to make the test browser less confused by things like the recent portlet and the navtree.

>>> self.portal.error_log._ignored_exceptions = ()
>>> self.portal.left_slots = self.portal.right_slots = []
>>> workflow = self.portal.portal_workflow

Validate mailhost replacement

>>> self.portal.MailHost
<MockMailHost at ...>
>>> from Products.CMFCore.utils import getToolByName
>>> getToolByName(self.portal, 'MailHost')
<MockMailHost at ...>
>>> from zope.component import getUtility
>>> from Products.MailHost.interfaces import IMailHost
>>> getUtility(IMailHost)
<MockMailHost at ...>

Send email

>>> msg = """To: member@example.com
...
... Dear Sir:
...
... Thank you"""
>>> self.portal.MailHost.send(msg)
>>> len(self.portal.MailHost.messages)
1
>>> self.portal.MailHost.messages[0]
'To: member@example.com...'
>>> self.portal.MailHost.messages[0]
'...Dear Sir:...'
>>> self.portal.MailHost.messages[0]
'...Thank you...'
>>> self.portal.MailHost.messages[0]
'...Dear Sir:...Thank you...'
>>> self.portal.MailHost.reset()
>>> len(self.portal.MailHost.messages)
0
>>> self.portal.MailHost.reset()
>>> self.portal.MailHost.send(msg, mto='member@example.com',
...                                mfrom='admin@example.com')
>>> len(self.portal.MailHost.messages)
1

Changelog

0.5 - 2012-09-25

  • Remove ZopeSkel and Paster dependency from setup.py [saily]
  • Moved to github and changed to README.rst, links in setup.py [saily]
  • Allow multiple paramters for send and secureSend method in MockMailHost class. [saily]

0.4 (2011-05-17)

  • Register MockMailHost in SiteManager to get MockMailHost when using getToolByName(context, 'MailHost') or getUtility(IMailHost). [saily]
  • Inherit from MailHost instead of SimpleItem [saily]
  • Implement the secureSend method [saily]

0.3 (2011-04-04)

  • Add **kwargs to MockMailHost’s send method to support mto, mfrom, … keyword arguments as default MailHost does. [saily]
  • Added file for generic setup various handlers [sureshvv]

0.2 (2010-05-21)

  • Added tests [sureshvv]

0.1 (2010-05-16)

  • Initial release [sureshvv]

Release history Release notifications

History Node

1.0

History Node

0.9

History Node

0.8

History Node

0.7

History Node

0.6

This version
History Node

0.5

History Node

0.4

History Node

0.3

History Node

0.2

History Node

0.2dev

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
collective.MockMailHost-0.5.zip (22.3 kB) Copy SHA256 hash SHA256 Source None Sep 25, 2012

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page