Ejemplo n.º 1
0
    def test_execute(self):
        from Acquisition import Implicit
        from Testing.makerequest import makerequest
        from plone.app.z3cform.csrf import AuthenticatedButtonActions
        from plone.protect import createToken

        class DummyForm(object):
            enableCSRFProtection = True

        class DummyAction(object):
            def isExecuted(self):
                return True

            def execute(self):
                self.called = True

        form = DummyForm()
        request = makerequest(Implicit()).REQUEST
        request.form['_authenticator'] = createToken()
        actions = AuthenticatedButtonActions(form, request, None)
        actions._data['foo'] = action = DummyAction()
        actions._data_keys = ['foo']
        actions._data_values = [action]

        actions.execute()
Ejemplo n.º 2
0
 def test_makerequest(self):
     # The argument must support acquisition.
     self.assertRaises(AttributeError, makerequest, object())
     # After the call, it will have a REQUEST attribute.
     item = Implicit()
     self.assertFalse(hasattr(item, 'REQUEST'))
     item = makerequest(item)
     self.assertTrue(hasattr(item, 'REQUEST'))
Ejemplo n.º 3
0
 def __init__(self, namespace):
   self.namespace = namespace
   Implicit.__init__(self)
Ejemplo n.º 4
0
 def __getattr__(self, name):
     try:
         return getattr(self._organization, name)
     except AttributeError:
         return Implicit.__getattr__(self, name)