-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "migrate all tests to use dexterity, fix most tests."
This reverts commit 0093daa.
- Loading branch information
Showing
25 changed files
with
152 additions
and
177 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Base class for integration tests, based on plone.app.testing | ||
""" | ||
from plone.app.contentrules.testing import PLONE_APP_CONTENTRULES_INTEGRATION_TESTING # noqa: E501 | ||
from plone.app.testing import login | ||
from plone.app.testing import setRoles | ||
from plone.app.testing import TEST_USER_ID | ||
from plone.app.testing import TEST_USER_NAME | ||
from zope.component import getMultiAdapter | ||
|
||
import unittest | ||
from plone.app.testing.bbb import PloneTestCase | ||
from zope.component import getMultiAdapter | ||
|
||
|
||
class ContentRulesTestCase(unittest.TestCase): | ||
class ContentRulesTestCase(PloneTestCase): | ||
"""Base class for integration tests for plone.app.contentrules. | ||
This may provide specific set-up and tear-down operations, or provide | ||
convenience methods. | ||
""" | ||
|
||
layer = PLONE_APP_CONTENTRULES_INTEGRATION_TESTING | ||
|
||
def setUp(self): | ||
self.portal = self.layer['portal'] | ||
self.request = self.layer['request'] | ||
login(self.portal, TEST_USER_NAME) | ||
setRoles(self.portal, TEST_USER_ID, ['Manager']) | ||
self.portal.invokeFactory('Folder', 'f1') | ||
self.folder = self.portal['f1'] | ||
self.folder.invokeFactory('Document', 'd1') | ||
self.portal.invokeFactory('Folder', 'target') | ||
|
||
def addAuthToRequest(self): | ||
portal = self.layer['portal'] | ||
request = self.layer['request'] | ||
authenticator = getMultiAdapter( | ||
(portal, request), name=u'authenticator') | ||
auth = authenticator.authenticator().split('value="')[1].rstrip('"/>') | ||
request.form['_authenticator'] = auth | ||
|
||
|
||
class ContentRulesFunctionalTestCase(PloneTestCase): | ||
"""Base class for functional integration tests for plone.app.contentrules. | ||
This may provide specific set-up and tear-down operations, or provide | ||
convenience methods. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,11 @@ def __init__(self, object): | |
|
||
class TestMailAction(ContentRulesTestCase): | ||
|
||
def setUp(self): | ||
super(TestMailAction, self).setUp() | ||
self.folder['d1'].setTitle(u'Wälkommen') | ||
def afterSetUp(self): | ||
self.setRoles(('Manager', )) | ||
self.portal.invokeFactory('Folder', 'target') | ||
self.folder.invokeFactory('Document', 'd1', | ||
title='W\xc3\xa4lkommen'.decode('utf-8')) | ||
|
||
users = ( | ||
('userone', 'User One', '[email protected]', ('Manager', 'Member')), | ||
|
@@ -108,14 +110,16 @@ def testInvokeEditView(self): | |
|
||
def testExecute(self): | ||
# this avoids sending mail as [email protected] | ||
self.loginAsPortalOwner() | ||
self.portal.portal_membership.getAuthenticatedMember().setProperties( | ||
email='[email protected]') | ||
dummyMailHost = self._setup_mockmail() | ||
e = MailAction() | ||
e.source = '$user_email' | ||
e.recipients = '[email protected], [email protected], $reviewer_emails, ' \ | ||
'$manager_emails, $member_emails' | ||
e.message = u"Päge '${title}' created in ${url} !" | ||
e.message = "P\xc3\xa4ge '${title}' created in ${url} !".decode( | ||
'utf-8') | ||
ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), | ||
IExecutable) | ||
ex() | ||
|
@@ -130,8 +134,9 @@ def testExecute(self): | |
self.assertEqual('[email protected]', mailSent.get('From')) | ||
# The output message should be a utf-8 encoded string | ||
self.assertEqual( | ||
u"Päge 'Wälkommen' created in http://nohost/plone/f1/d1 !", | ||
mailSent.get_payload()) | ||
"P\xc3\xa4ge 'W\xc3\xa4lkommen' created in " | ||
'http://nohost/plone/Members/test_user_1_/d1 !', | ||
mailSent.get_payload(decode=True)) | ||
|
||
# check interpolation of $reviewer_emails | ||
self.assertTrue('[email protected]' in sent_mails) | ||
|
@@ -176,7 +181,7 @@ def testExecuteNoSource(self): | |
self.assertEqual('"plone@rulez" <[email protected]>', | ||
mailSent.get('From')) | ||
self.assertEqual('Document created !', | ||
mailSent.get_payload()) | ||
mailSent.get_payload(decode=True)) | ||
self._teardown_mockmail() | ||
|
||
def testExecuteMultiRecipients(self): | ||
|
@@ -195,14 +200,14 @@ def testExecuteMultiRecipients(self): | |
self.assertEqual('[email protected]', mailSent.get('To')) | ||
self.assertEqual('[email protected]', mailSent.get('From')) | ||
self.assertEqual('Document created !', | ||
mailSent.get_payload()) | ||
mailSent.get_payload(decode=True)) | ||
mailSent = message_from_string(dummyMailHost.messages[1]) | ||
self.assertEqual('text/plain; charset="utf-8"', | ||
mailSent.get('Content-Type')) | ||
self.assertEqual('[email protected]', mailSent.get('To')) | ||
self.assertEqual('[email protected]', mailSent.get('From')) | ||
self.assertEqual('Document created !', | ||
mailSent.get_payload()) | ||
mailSent.get_payload(decode=True)) | ||
self._teardown_mockmail() | ||
|
||
def testExecuteExcludeActor(self): | ||
|
@@ -241,6 +246,7 @@ def testExecuteNoRecipients(self): | |
) | ||
def testExecuteBadMailHost(self): | ||
# Our goal is that mailing errors should not cause exceptions | ||
self.loginAsPortalOwner() | ||
self.portal.portal_membership.getAuthenticatedMember().setProperties( | ||
email='[email protected]') | ||
e = MailAction() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
bccf6ba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pbauer Jenkins CI reporting about code analysis
See the full report here: https://jenkins.plone.org/job/package-plone.app.contentrules/46/violations
Follow these instructions to reproduce it locally.