-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2729d48
commit b658d12
Showing
4 changed files
with
205 additions
and
27 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# -*- coding: utf-8 -*- | ||
from collective.ifttt.actions.ifttt import PAYLOAD_DESCRIPTION | ||
from collective.ifttt.testing import COLLECTIVE_IFTTT_INTEGRATION_TESTING | ||
from plone.app.contentrules.conditions.wfstate import WorkflowStateCondition | ||
from plone.app.testing import setRoles | ||
from plone.app.testing import TEST_USER_ID | ||
from plone.contentrules.engine.interfaces import IRuleStorage | ||
from Products.CMFCore.interfaces._events import IActionSucceededEvent | ||
from zope.component import getMultiAdapter | ||
from zope.component import getUtility | ||
|
||
import unittest | ||
|
||
|
||
class TestActionMenu(unittest.TestCase): | ||
layer = COLLECTIVE_IFTTT_INTEGRATION_TESTING | ||
|
||
def setUp(self): | ||
|
||
self.portal = self.layer['portal'] | ||
setRoles(self.portal, TEST_USER_ID, ['Manager']) | ||
self.request = self.layer['request'] | ||
|
||
def test_view(self): | ||
# Check existence of IFTTT Action Menu | ||
|
||
self.view = getMultiAdapter((self.portal, self.request), | ||
name='ifttt_content_trigger') | ||
actions_view = self.view() | ||
self.assertIn('including the description of content', actions_view) | ||
|
||
def test_add(self): | ||
|
||
self.request.method = 'POST' | ||
self.request.form['form.widgets.ifttt_event_name'] = 'Test' | ||
self.request.form['form.widgets.content_types'] = [ | ||
'Document', 'News Item' | ||
] | ||
self.request.form['form.widgets.workflow_transitions'] = [ | ||
'publish', 'reject' | ||
] | ||
self.request.form['form.buttons.add'] = u'Add' | ||
self.view = getMultiAdapter((self.portal, self.request), | ||
name='ifttt_content_trigger') | ||
self.view() | ||
|
||
storage = getUtility(IRuleStorage) | ||
|
||
# check that rule has been successfully created | ||
self.assertEqual(1, len(storage)) | ||
self.assertEqual(IActionSucceededEvent, storage.values()[0].event) | ||
# workflow_state to be published is | ||
# default condition of content_trigger | ||
self.assertEqual(5, len(storage.values()[0].conditions)) | ||
self.assertEqual( | ||
WorkflowStateCondition, | ||
storage.values()[0].conditions[-1].__class__ | ||
) | ||
self.assertEqual( | ||
'Test', | ||
storage.values()[0].actions[0].ifttt_event_name | ||
) | ||
self.assertEqual( | ||
'plone.actions.Ifttt', | ||
storage.values()[0].actions[0].element | ||
) | ||
self.assertEqual( | ||
PAYLOAD_DESCRIPTION, | ||
storage.values()[0].actions[0].payload_option | ||
) |
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# -*- coding: utf-8 -*- | ||
from collective.ifttt.actions.ifttt import PAYLOAD_START | ||
from collective.ifttt.testing import COLLECTIVE_IFTTT_INTEGRATION_TESTING | ||
from plone.app.contentrules.conditions.portaltype import PortalTypeCondition | ||
from plone.app.contentrules.conditions.wfstate import WorkflowStateCondition | ||
from plone.app.testing import setRoles | ||
from plone.app.testing import TEST_USER_ID | ||
from plone.contentrules.engine.interfaces import IRuleStorage | ||
from Products.CMFCore.interfaces._events import IActionSucceededEvent | ||
from zope.component import getMultiAdapter | ||
from zope.component import getUtility | ||
|
||
import unittest | ||
|
||
|
||
class TestActionMenu(unittest.TestCase): | ||
layer = COLLECTIVE_IFTTT_INTEGRATION_TESTING | ||
|
||
def setUp(self): | ||
|
||
self.portal = self.layer['portal'] | ||
setRoles(self.portal, TEST_USER_ID, ['Manager']) | ||
self.request = self.layer['request'] | ||
|
||
def test_view(self): | ||
# Check existence of IFTTT Action Menu | ||
|
||
self.view = getMultiAdapter((self.portal, self.request), | ||
name='ifttt_event_trigger') | ||
actions_view = self.view() | ||
self.assertIn('including the datetime of event', actions_view) | ||
|
||
def test_add(self): | ||
|
||
self.request.method = 'POST' | ||
self.request.form['form.widgets.ifttt_event_name'] = 'Test' | ||
self.request.form['form.widgets.workflow_transitions'] = [ | ||
'publish', 'reject' | ||
] | ||
self.request.form['form.buttons.add'] = u'Add' | ||
self.view = getMultiAdapter((self.portal, self.request), | ||
name='ifttt_event_trigger') | ||
self.view() | ||
|
||
storage = getUtility(IRuleStorage) | ||
|
||
# check that rule has been successfully created | ||
self.assertEqual(1, len(storage)) | ||
self.assertEqual(IActionSucceededEvent, storage.values()[0].event) | ||
# workflow_state to be published and content_types to be events | ||
# is default condition of content_trigger | ||
self.assertEqual(4, len(storage.values()[0].conditions)) | ||
self.assertEqual( | ||
WorkflowStateCondition, | ||
storage.values()[0].conditions[-1].__class__ | ||
) | ||
self.assertEqual( | ||
PortalTypeCondition, | ||
storage.values()[0].conditions[0].__class__ | ||
) | ||
self.assertEqual( | ||
'Test', | ||
storage.values()[0].actions[0].ifttt_event_name | ||
) | ||
self.assertEqual( | ||
'plone.actions.Ifttt', | ||
storage.values()[0].actions[0].element | ||
) | ||
self.assertEqual( | ||
PAYLOAD_START, | ||
storage.values()[0].actions[0].payload_option | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# -*- coding: utf-8 -*- | ||
from collective.ifttt.actions.ifttt import PAYLOAD_USERNAME | ||
from collective.ifttt.testing import COLLECTIVE_IFTTT_INTEGRATION_TESTING | ||
from plone.app.contentrules.conditions.wfstate import WorkflowStateCondition # noqa | ||
from plone.app.testing import setRoles | ||
from plone.app.testing import TEST_USER_ID | ||
from plone.contentrules.engine.interfaces import IRuleStorage | ||
from zope.component import getMultiAdapter | ||
from zope.component import getUtility | ||
from zope.lifecycleevent.interfaces import IObjectModifiedEvent | ||
|
||
import unittest | ||
|
||
|
||
class TestActionMenu(unittest.TestCase): | ||
layer = COLLECTIVE_IFTTT_INTEGRATION_TESTING | ||
|
||
def setUp(self): | ||
|
||
self.portal = self.layer['portal'] | ||
setRoles(self.portal, TEST_USER_ID, ['Manager']) | ||
self.request = self.layer['request'] | ||
|
||
def test_view(self): | ||
# Check existence of IFTTT Action Menu | ||
|
||
self.view = getMultiAdapter((self.portal, self.request), | ||
name='ifttt_user_trigger') | ||
actions_view = self.view() | ||
self.assertIn( | ||
'including the information of who changed it', actions_view | ||
) | ||
|
||
def test_add(self): | ||
|
||
self.request.method = 'POST' | ||
self.request.form['form.widgets.ifttt_event_name'] = 'Test' | ||
self.request.form['form.widgets.content_types'] = [ | ||
'Document', 'News Item' | ||
] | ||
self.request.form['form.buttons.add'] = u'Add' | ||
self.view = getMultiAdapter((self.portal, self.request), | ||
name='ifttt_user_trigger') | ||
self.view() | ||
|
||
storage = getUtility(IRuleStorage) | ||
|
||
# check that rule has been successfully created | ||
self.assertEqual(1, len(storage)) | ||
self.assertEqual(IObjectModifiedEvent, storage.values()[0].event) | ||
self.assertEqual(2, len(storage.values()[0].conditions)) | ||
self.assertEqual( | ||
'Test', | ||
storage.values()[0].actions[0].ifttt_event_name | ||
) | ||
self.assertEqual( | ||
'plone.actions.Ifttt', | ||
storage.values()[0].actions[0].element | ||
) | ||
self.assertEqual( | ||
PAYLOAD_USERNAME, | ||
storage.values()[0].actions[0].payload_option | ||
) |