Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vangheem committed Jul 2, 2015
1 parent c6959d0 commit 9e5a0a2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
40 changes: 33 additions & 7 deletions Products/PasswordResetTool/tests/test_doctests.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
from Products.CMFPlone.interfaces import IMailSchema
from zope.component import getUtility
from plone.registry.interfaces import IRegistry
"""
PasswordResetTool doctests
"""

import doctest
import unittest
from Products.MailHost.interfaces import IMailHost
from zope.component import getSiteManager
from Acquisition import aq_base

from Acquisition import aq_base
from Products.CMFPlone.tests.utils import MockMailHost
from Products.MailHost.interfaces import IMailHost
from plone.app import testing
from plone.registry.interfaces import IRegistry
from plone.testing import layered
from transaction import commit
from zope.component import getSiteManager
from zope.component import getUtility

try:
from Products.CMFPlone.interfaces.controlpanel import IMailSchema
HAS_REGISTRY_MAIL_SETTINGS = True
# work with plone 4 yet...
except ImportError:
HAS_REGISTRY_MAIL_SETTINGS = False


OPTIONFLAGS = (doctest.ELLIPSIS |
doctest.NORMALIZE_WHITESPACE |
Expand Down Expand Up @@ -47,8 +54,27 @@ def tearDownPloneSite(self, portal):
provided=IMailHost
)


class Layer(testing.FunctionalTesting):

def set_email_from_name(self, name):
if HAS_REGISTRY_MAIL_SETTINGS:
registry = getUtility(IRegistry)
mail_settings = registry.forInterface(IMailSchema, prefix="plone")
mail_settings.email_from_name = name
else:
self['portal'].email_from_name = name

def set_email_from_address(self, address):
if HAS_REGISTRY_MAIL_SETTINGS:
registry = getUtility(IRegistry)
mail_settings = registry.forInterface(IMailSchema, prefix="plone")
mail_settings.email_from_address = address
else:
self['portal'].email_from_address = address

MOCK_MAIL_FIXTURE = MockMailFixture()
MM_FUNCTIONAL_TESTING = testing.FunctionalTesting(
MM_FUNCTIONAL_TESTING = Layer(
bases=(MOCK_MAIL_FIXTURE, ),
name='PloneTestCase:Functional'
)
Expand Down
4 changes: 2 additions & 2 deletions Products/PasswordResetTool/tests/view.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Test passwordreset BrowserView
Setup Plone email sender

>>> portal = layer['portal']
>>> portal.email_from_name=u'Old\u0159ich a Bo\u017eena'
>>> portal.email_from_address='smith@example.com'
>>> layer.set_email_from_name(u'Old\u0159ich a Bo\u017eena')
>>> layer.set_email_from_address('smith@example.com')
>>> portal.title=u'Koko\u0159\xedn Portal'

Check view methods
Expand Down

0 comments on commit 9e5a0a2

Please sign in to comment.