Esempio n. 1
0
    def test_fires_edit_cancelled_event(self):

        # Context and request
        context_mock = self.create_dummy(portal_type=u'testtype', title=u'foo')
        context_mock.absolute_url = \
            lambda *a, **kw: 'http://127.0.0.1/plone/item'
        request_mock = TestRequest()

        # mock status message
        @implementer(IStatusMessage)
        class StatusMessage(object):

            def __init__(self, request):
                pass

            def addStatusMessage(self, msg, type=''):
                pass
        self.mock_adapter(StatusMessage, IStatusMessage, (Interface,))

        # mock notify
        from zope.event import notify
        notify_mock = self.patch_global(notify)

        # Form
        view = DefaultEditForm(context_mock, request_mock)
        view.handleCancel(view, {})

        self.assertTrue(notify_mock.called)
        self.assertTrue(
            IEditCancelledEvent.providedBy(notify_mock.call_args[0][0]))
Esempio n. 2
0
    def test_fires_edit_cancelled_event(self):

        # Context and request

        context_mock = self.create_dummy(portal_type=u'testtype', title=u'foo')
        context_mock.absolute_url = \
            lambda *a, **kw: 'http://127.0.0.1/plone/item'
        request_mock = TestRequest()

        # mock status message
        class StatusMessage(object):
            implements(IStatusMessage)

            def __init__(self, request):
                pass

            def addStatusMessage(self, msg, type=''):
                pass

        self.mock_adapter(StatusMessage, IStatusMessage, (Interface, ))

        # mock notify
        notify_mock = self.mocker.replace('zope.event.notify')
        self.expect(
            notify_mock(
                mocker.MATCH(lambda x: IEditCancelledEvent.providedBy(x))))

        # Form
        self.replay()

        view = DefaultEditForm(context_mock, request_mock)
        view.handleCancel(view, {})
Esempio n. 3
0
    def test_fires_edit_cancelled_event(self):

        # Context and request

        context_mock = self.create_dummy(portal_type=u'testtype', title=u'foo')
        context_mock.absolute_url = lambda *a, **kw: 'http://127.0.0.1/plone/item'
        request_mock = TestRequest()

        # mock status message
        class StatusMessage(object):
            implements(IStatusMessage)
            def __init__(self, request):
                pass
            def addStatusMessage(self, msg, type=''):
                pass
        self.mock_adapter(StatusMessage, IStatusMessage, (Interface,))

        # mock notify
        notify_mock = self.mocker.replace('zope.event.notify')
        self.expect(notify_mock(mocker.MATCH(
                    lambda x: IEditCancelledEvent.providedBy(x)
                    )))

        # Form
        self.replay()

        view = DefaultEditForm(context_mock, request_mock)
        view.handleCancel(view, {})
Esempio n. 4
0
    def test_fires_edit_cancelled_event(self):

        # Context and request
        context_mock = self.create_dummy(portal_type=u'testtype', title=u'foo')
        context_mock.absolute_url = \
            lambda *a, **kw: 'http://127.0.0.1/plone/item'
        request_mock = TestRequest()

        # mock status message
        @implementer(IStatusMessage)
        class StatusMessage(object):
            def __init__(self, request):
                pass

            def addStatusMessage(self, msg, type=''):
                pass

        self.mock_adapter(StatusMessage, IStatusMessage, (Interface, ))

        # mock notify
        from zope.event import notify
        notify_mock = self.patch_global(notify)

        # Form
        view = DefaultEditForm(context_mock, request_mock)
        view.handleCancel(view, {})

        self.assertTrue(notify_mock.called)
        self.assertTrue(
            IEditCancelledEvent.providedBy(notify_mock.call_args[0][0]))