Beispiel #1
0
    def setUp(self):
        self.portal = self.layer['portal']
        self.request = self.layer['request']

        eventtesting.setUp()

        self.tile = PersistentCoverTile(self.portal, self.request)
    def setUp(self):
        self.portal = self.layer['portal']
        self.request = self.layer['request']

        eventtesting.setUp()

        self.tile = PersistentCoverTile(self.portal, self.request)
 def setUp(self):
     super(BaseTileTestCase, self).setUp()
     eventtesting.setUp()
     self._register_tile()
     self.tile = PersistentCoverTile(self.cover, self.request)
     self.tile.__name__ = u'collective.cover.base'
     self.tile.id = u'test'
 def setUp(self):
     super(BaseTileTestCase, self).setUp()
     eventtesting.setUp()
     self._register_tile()
     self.tile = PersistentCoverTile(self.cover, self.request)
     self.tile.__name__ = u'collective.cover.base'
     self.tile.id = u'test'
    def setUp(self):
        componenttesting.setUp()
        eventtesting.setUp()
        zcml.load_config("meta.zcml", zope.component)
        zcml.load_config("configure.zcml", Products.StandardCacheManagers)

        folder1, folder2 = self._initFolders()

        folder1.all_meta_types = folder2.all_meta_types = CACHE_META_TYPES

        self.folder1 = folder1
        self.folder2 = folder2

        self.policy = UnitTestSecurityPolicy()
        self.oldPolicy = SecurityManager.setSecurityPolicy(self.policy)

        cm_id = "cache"
        manager = self._makeOne(cm_id)
        self.folder1._setObject(cm_id, manager)
        self.cachemanager = self.folder1[cm_id]
        transaction.savepoint(optimistic=True)

        newSecurityManager(None, UnitTestUser().__of__(self.root))

        CopySupportTestBase.setUp(self)
    def setUp(self):
        componenttesting.setUp()
        eventtesting.setUp()
        zcml.load_config('meta.zcml', zope.component)
        zcml.load_config('configure.zcml', Products.StandardCacheManagers)

        folder1, folder2 = self._initFolders()

        folder1.all_meta_types = folder2.all_meta_types = CACHE_META_TYPES

        self.folder1 = folder1
        self.folder2 = folder2

        self.policy = UnitTestSecurityPolicy()
        self.oldPolicy = SecurityManager.setSecurityPolicy(self.policy)

        cm_id = 'cache'
        manager = self._makeOne(cm_id)
        self.folder1._setObject(cm_id, manager)
        self.cachemanager = self.folder1[cm_id]
        transaction.savepoint(optimistic=True)

        newSecurityManager(None, UnitTestUser().__of__(self.root))

        CopySupportTestBase.setUp(self)
Beispiel #7
0
def setUp(test):
    cleanup.setUp()
    eventtesting.setUp()
    provideAdapter(AttributeAnnotations)
    provideAdapter(AnnotationPrincipalRoleManager, adapts=(IAnnotatable, ))
    provideAdapter(Ownership)
    provideHandler(setOwner)
    provideUtility(principalRegistry, IAuthentication)
    test.globs = {'authentication': principalRegistry}
    def setUp(self):
        self.portal = self.layer['portal']
        self.request = self.layer['request']

        eventtesting.setUp()

        self._register_tile()
        self.tile = PersistentCoverTile(self.portal, self.request)
        # XXX: tile initialization
        self.tile.__name__ = 'collective.cover.base'
Beispiel #9
0
def setup_test():
    eventtesting.setUp()
    load_zcml(os.path.join(
        os.path.dirname(dolmen.relations.__file__), 'configure.zcml'))
    load_zcml(os.path.join(
        os.path.dirname(dolmen.relations.__file__), 'subscribers.zcml'))
    sm = component.getGlobalSiteManager()
    sm.registerUtility(IntIds(), IIntIds)
    sm.registerAdapter(connectionOfPersistent, (IPersistent,), IConnection)
    sm.registerAdapter(KeyReferenceToPersistent, (IPersistent,), IKeyReference)
    def setUp(self):
        self.portal = self.layer['portal']
        self.request = self.layer['request']

        eventtesting.setUp()

        self._register_tile()
        self.tile = PersistentCoverTile(self.portal, self.request)
        # XXX: tile initialization
        self.tile.__name__ = 'collective.cover.base'
Beispiel #11
0
    def setUp(self):
        from zope.component import provideHandler
        from zope.component.interfaces import IObjectEvent
        from Products.CMFCore.interfaces import ICookieCrumbler
        from Products.CMFCore.CookieCrumbler import handleCookieCrumblerEvent

        self._finally = None

        eventtesting.setUp()
        provideHandler(handleCookieCrumblerEvent,
                       adapts=(ICookieCrumbler, IObjectEvent))
Beispiel #12
0
    def setUp(self):
        from zope.component import provideHandler
        from zope.component.interfaces import IObjectEvent
        from Products.CMFCore.interfaces import ICookieCrumbler
        from Products.CMFCore.CookieCrumbler import handleCookieCrumblerEvent

        self._finally = None

        eventtesting.setUp()
        provideHandler(handleCookieCrumblerEvent,
                       adapts=(ICookieCrumbler, IObjectEvent))
    def setUp(self):
        self.ideal = getUtility(IMollieIdeal)
        self.ideal.old_do_request = self.ideal._do_request
        self.ideal._do_request = MagicMock(
            side_effect=self._side_effect)

        self.foo = Foo()
        self.adapted = IMollieIdealPayment(self.foo)
        self.adapted._partner_id = '999999'
        self.adapted.transaction_id = '482d599bbcc7795727650330ad65fe9b'
        eventtesting.setUp()
Beispiel #14
0
def setUp(test):
    setup.placefulSetUp()
    setUpContents()

    eventtesting.setUp()
    component.provideAdapter(idgenerator.NameChooser)

    component.provideHandler(topic.topicIdAddedHandler)
    component.provideHandler(topic.topicModifiedHandler)
    component.provideHandler(topic.topicRemovedHandler)
    component.provideHandler(message.messageModifiedHandler)
    def setUp(self):
        """Custom shared utility setup for tests."""
        self.portal = self.layer['portal']
        self.ipn = queryAdapter(self.portal, IIPN)
        self.log = InstalledHandler('niteoweb.ipn.core')
        eventtesting.setUp()

        # create a test member and a test product group
        api.user.create(email='*****@*****.**')
        api.group.create(groupname='ipn_1')
        api.group.add_user(username='******', groupname='ipn_1')
Beispiel #16
0
def placefulSetUp(site=False):
    testing.setUp()
    eventtesting.setUp()
    traversingSetUp()
    setHooks()
    provideAdapter(ContainerTraversable,
                   (ISimpleReadContainer,), ITraversable)
    provideAdapter(SiteManagerAdapter, (Interface,), IComponentLookup)

    if site:
        root = rootFolder()
        createSiteManager(root, setsite=True)
        return root
    def setUp(self):
        self.ideal = getUtility(IMollieIdeal)
        self.ideal.old_do_request = self.ideal._do_request
        self.ideal._do_request = MagicMock(
            side_effect=self._side_effect)

        self.foo = Foo()
        self.transaction_id = '482d599bbcc7795727650330ad65fe9b'
        self.adapted = IMollieIdealMultiplePayments(self.foo)
        self.adapted._metadata[self.transaction_id] = {
            'partner_id': '999999',
            }
        eventtesting.setUp()
    def setUp(self):
        """Custom shared utility setup for tests."""
        self.portal = self.layer['portal']
        self.request = self.layer['request']
        self.ipn = queryAdapter(self.portal, IIPN)
        self.log = InstalledHandler('niteoweb.ipn.core')
        eventtesting.setUp()

        # set a very long valid_to date for the test_user
        # in order to skip this one in our tests below
        test_user = api.user.get(username=TEST_USER_ID)
        test_user.setMemberProperties(
            mapping={'valid_to': DateTime('2020/01/01')})
Beispiel #19
0
    def setUp(self):
        ZCMLFileLayer.setUp(self)
        eventtesting.setUp()
        traversingSetUp()
        zope.component.hooks.setHooks()

        # Set up site manager adapter
        zope.component.provideAdapter(
            SiteManagerAdapter, (Interface,), IComponentLookup)

        # Set up site
        site = rootFolder()
        site.setSiteManager(LocalSiteManager(site))
        zope.component.hooks.setSite(site)
    def setUp(self):
        """Custom shared utility setup for tests."""
        self.portal = self.layer['portal']
        self.ipn = queryAdapter(self.portal, IIPN)
        self.log = InstalledHandler('niteoweb.ipn.core')
        eventtesting.setUp()

        # create test product groups and set their validity
        api.group.create(groupname='ipn_1')
        group = api.group.get(groupname='ipn_1')
        group.setGroupProperties(mapping={'validity': 31})

        api.group.create(groupname='ipn_2')
        group = api.group.get(groupname='ipn_2')
        group.setGroupProperties(mapping={'validity': 365})
Beispiel #21
0
    def setUp(self):
        testing.setUp()
        eventtesting.setUp()
        traversingSetUp()
        setHooks()
        provideAdapter(ContainerTraversable, (ISimpleReadContainer, ),
                       ITraversable)
        provideAdapter(SiteManagerAdapter, (Interface, ), IComponentLookup)

        self.root = rootFolder()
        createSiteManager(self.root, setsite=True)

        provideAdapter(connectionOfPersistent, (IPersistent, ), IConnection)
        provideAdapter(KeyReferenceToPersistent, (IPersistent, ),
                       IKeyReference)
Beispiel #22
0
    def setUp(self):
        testing.setUp()
        eventtesting.setUp()
        traversingSetUp()
        setHooks()
        provideAdapter(ContainerTraversable,
                       (ISimpleReadContainer,), ITraversable)
        provideAdapter(SiteManagerAdapter, (Interface,), IComponentLookup)

        self.root = rootFolder()
        createSiteManager(self.root, setsite=True)

        provideAdapter(connectionOfPersistent, (IPersistent, ), IConnection)
        provideAdapter(
            KeyReferenceToPersistent, (IPersistent, ), IKeyReference)
    def test_register_styles_record(self):
        registry = getUtility(IRegistry)
        record = 'collective.cover.controlpanel.ICoverSettings.styles'

        eventtesting.setUp()

        # just delete the existing record and rerun the handler to verify it
        # was added again
        del registry.records[record]
        eventtesting.clearEvents()
        register_styles_record(self.portal)
        events = eventtesting.getEvents(IRecordAddedEvent)
        self.assertNotEqual(len(events), 0)
        self.assertIn(record, registry.records)
        eventtesting.clearEvents()
    def test_automatic_purging(self):
        # z3c.caching must purge objects automatically on modified,
        # moved, renamed or removed; testing the whole enchilada is out
        # of the scope of this package
        from z3c.caching.interfaces import IPurgeEvent
        from zope.component import eventtesting
        from zope.event import notify
        from zope.lifecycleevent import ObjectModifiedEvent
        eventtesting.setUp()

        # modifying the poll must fire a Purge event
        notify(ObjectModifiedEvent(self.poll))
        events = eventtesting.getEvents()
        # XXX: Purge event is fired more than once
        #      https://community.plone.org/t/6411?u=hvelarde
        self.assertEventFiredOnce(IPurgeEvent, events)
Beispiel #25
0
def setUp(test):
    cleanup.setUp()
    eventtesting.setUp()

    from zope.browserpage.metaconfigure import registerType
    from zope.contentprovider import tales
    registerType('provider', tales.TALESProviderExpression)

    # Make sure we are always reloading page template files ;-)
    global mtime_func
    mtime_func = os.path.getmtime
    def number(x):
        global counter
        counter += 1
        return counter
    os.path.getmtime = number
Beispiel #26
0
def setUp(test):
    cleanup.setUp()
    eventtesting.setUp()
    traversingSetUp()

    # resource namespace setup
    from zope.traversing.interfaces import ITraversable
    from zope.traversing.namespace import resource
    zope.component.provideAdapter(
        resource, (None,), ITraversable, name = "resource")
    zope.component.provideAdapter(
        resource, (None, None), ITraversable, name = "resource")

    from zope.browserpage import metaconfigure
    from zope.contentprovider import tales
    metaconfigure.registerType('provider', tales.TALESProviderExpression)
Beispiel #27
0
    def _doSetUp(obj):
        obj._doSetUpSuper() # pylint:disable=protected-access
        setHooks() # zope.component.hooks registers a zope.testing.cleanup to reset these
        if obj.configure_events:
            if obj.set_up_packages:
                # If zope.component is being configured, we wind up with duplicates if we let
                # eventtesting fully configure itself
                component.provideHandler(eventtesting.events.append, (None,))
            else:
                eventtesting.setUp() # pragma: no cover

        obj.configuration_context = obj.configure_packages(
            set_up_packages=obj.set_up_packages,
            features=obj.features,
            context=obj.configuration_context,
            package=obj.get_configuration_package())
Beispiel #28
0
    def test_automatic_purging(self):
        # z3c.caching must purge objects automatically on modified,
        # moved, renamed or removed; testing the whole enchilada is out
        # of the scope of this package
        from z3c.caching.interfaces import IPurgeEvent
        from zope.component import eventtesting
        from zope.event import notify
        from zope.lifecycleevent import ObjectModifiedEvent
        eventtesting.setUp()

        # modifying the poll must fire a Purge event
        notify(ObjectModifiedEvent(self.poll))
        events = eventtesting.getEvents()
        # XXX: Purge event is fired more than once
        #      https://community.plone.org/t/6411?u=hvelarde
        self.assertEventFiredOnce(IPurgeEvent, events)
Beispiel #29
0
def doctestSetUp(test):
    cleanup.setUp()
    eventtesting.setUp()
    traversingSetUp()

    # resource namespace setup
    from zope.traversing.interfaces import ITraversable
    from zope.traversing.namespace import resource
    zope.component.provideAdapter(resource, (None, ),
                                  ITraversable,
                                  name="resource")
    zope.component.provideAdapter(resource, (None, None),
                                  ITraversable,
                                  name="resource")

    from zope.browserpage import metaconfigure
    from zope.contentprovider import tales
    metaconfigure.registerType('provider', tales.TALESProviderExpression)
Beispiel #30
0
def setUp(test):
    cleanup.setUp()
    eventtesting.setUp()

    from zope.browserpage.metaconfigure import registerType
    from zope.contentprovider import tales
    registerType('provider', tales.TALESProviderExpression)

    # Make sure we are always reloading page template files ;-)
    global mtime_func
    mtime_func = os.path.getmtime

    def number(x):
        global counter
        counter += 1
        return counter

    os.path.getmtime = number
Beispiel #31
0
    def setUp(self):
        super(BaseFunctionRunnerTestCase, self).setUp()
        eventtesting.setUp()

        def dummy_func(*args, **kwargs):
            return 'Bar'

        self.dummy_func = dummy_func
        self.args = ['foo', 'bar']
        self.kwargs = {
            'authorized_userid': SITE_OWNER_NAME,
            'site_path': '/plone',
        }
        self.task_kwargs = {'baz': 1}
        self.frunner = FunctionRunner(
            func=self.dummy_func,
            new_func=self.dummy_func,
            orig_args=self.args,
            orig_kw=self.kwargs,
            task_kw=self.task_kwargs,
        )
    def setUp(self):
        super(BaseFunctionRunnerTestCase, self).setUp()
        eventtesting.setUp()

        def dummy_func(*args, **kwargs):
            return 'Bar'

        self.dummy_func = dummy_func
        self.args = ['foo', 'bar']
        self.kwargs = {
            'authorized_userid': SITE_OWNER_NAME,
            'site_path': '/plone',
        }
        self.task_kwargs={'baz': 1}
        self.frunner = FunctionRunner(
            func=self.dummy_func,
            new_func=self.dummy_func,
            orig_args=self.args,
            orig_kw=self.kwargs,
            task_kw=self.task_kwargs,
        )
    def test_register_available_tiles_record(self):
        registry = getUtility(IRegistry)
        record = 'collective.cover.controlpanel.ICoverSettings.available_tiles'

        eventtesting.setUp()

        # calling the handler here should have no effect as we are running the
        # latest profile version
        eventtesting.clearEvents()
        register_available_tiles_record(self.portal)
        events = eventtesting.getEvents(IRecordAddedEvent)
        self.assertEqual(len(events), 0)

        # now we delete the record and rerun the handler to verify the record
        # was added
        del registry.records[record]
        eventtesting.clearEvents()
        register_available_tiles_record(self.portal)
        events = eventtesting.getEvents(IRecordAddedEvent)
        self.assertNotEqual(len(events), 0)
        self.assertIn(record, registry.records)
        eventtesting.clearEvents()
Beispiel #34
0
    def test_register_styles_record(self):
        registry = getUtility(IRegistry)
        record = 'collective.cover.controlpanel.ICoverSettings.styles'

        eventtesting.setUp()

        # calling the handler here should have no effect as we are running the
        # latest profile version
        eventtesting.clearEvents()
        register_styles_record(self.portal)
        events = eventtesting.getEvents(IRecordAddedEvent)
        self.assertEqual(len(events), 0)

        # now we delete the record and rerun the handler to verify the record
        # was added
        del registry.records[record]
        eventtesting.clearEvents()
        register_styles_record(self.portal)
        events = eventtesting.getEvents(IRecordAddedEvent)
        self.assertNotEqual(len(events), 0)
        self.assertIn(record, registry.records)
        eventtesting.clearEvents()
Beispiel #35
0
    def test_delete_tile_removes_persistent_data(self):
        # https://github.com/scmos.scmos.cover/issues/765
        from scmos.cover.config import CONFIGURATION_PREFIX
        from scmos.cover.config import PERMISSIONS_PREFIX
        from zope.annotation import IAnnotations
        from zope.component import eventtesting
        from zope.lifecycleevent import IObjectModifiedEvent
        eventtesting.setUp()
        annotations = IAnnotations(self.tile.context)

        data_mgr = ITileDataManager(self.tile)
        data_mgr.set({'test': 'data'})
        self.assertIn('test', data_mgr.get())
        self.assertEqual(data_mgr.get()['test'], 'data')

        permissions = getMultiAdapter((self.cover, self.request, self.tile),
                                      ITilesPermissions)
        permissions.set_allowed_edit('masters_of_the_universe')
        self.assertIn(PERMISSIONS_PREFIX + '.test', annotations)

        configuration = getMultiAdapter((self.cover, self.request, self.tile),
                                        ITilesConfigurationScreen)
        configuration.set_configuration({'uuid': 'c1d2e3f4g5jrw'})
        self.assertIn(CONFIGURATION_PREFIX + '.test', annotations)

        # Call the delete method
        eventtesting.clearEvents()
        self.tile.delete()

        # Now we should not see the persistent data anymore
        self.assertNotIn('test', data_mgr.get())
        self.assertNotIn(PERMISSIONS_PREFIX + '.test', annotations)
        self.assertNotIn(CONFIGURATION_PREFIX + '.test', annotations)

        # Finally, test that ObjectModifiedEvent was fired for the cover
        events = eventtesting.getEvents()
        self.assertEqual(len(events), 1)
        self.assertTrue(IObjectModifiedEvent.providedBy(events[0]))
    def test_delete_tile_removes_persistent_data(self):
        # https://github.com/collective/collective.cover/issues/765
        from collective.cover.config import CONFIGURATION_PREFIX
        from collective.cover.config import PERMISSIONS_PREFIX
        from zope.annotation import IAnnotations
        from zope.component import eventtesting
        from zope.lifecycleevent import IObjectModifiedEvent
        eventtesting.setUp()
        annotations = IAnnotations(self.tile.context)

        data_mgr = ITileDataManager(self.tile)
        data_mgr.set({'test': 'data'})
        self.assertIn('test', data_mgr.get())
        self.assertEqual(data_mgr.get()['test'], 'data')

        permissions = getMultiAdapter(
            (self.cover, self.request, self.tile), ITilesPermissions)
        permissions.set_allowed_edit('masters_of_the_universe')
        self.assertIn(PERMISSIONS_PREFIX + '.test', annotations)

        configuration = getMultiAdapter(
            (self.cover, self.request, self.tile), ITilesConfigurationScreen)
        configuration.set_configuration({'uuid': 'c1d2e3f4g5jrw'})
        self.assertIn(CONFIGURATION_PREFIX + '.test', annotations)

        # Call the delete method
        eventtesting.clearEvents()
        self.tile.delete()

        # Now we should not see the persistent data anymore
        self.assertNotIn('test', data_mgr.get())
        self.assertNotIn(PERMISSIONS_PREFIX + '.test', annotations)
        self.assertNotIn(CONFIGURATION_PREFIX + '.test', annotations)

        # Finally, test that ObjectModifiedEvent was fired for the cover
        events = eventtesting.getEvents()
        self.assertEqual(len(events), 1)
        self.assertTrue(IObjectModifiedEvent.providedBy(events[0]))
Beispiel #37
0
def module_setup(set_up_packages=(),
                 features=('devmode', 'testmode'),
                 configure_events=True):
    """
    A module-level fixture for configuring packages.

    Either import this as ``setUpModule`` at the module level, or call
    it to perform module level set up from your own function with that name.
    If you use this, you must also use :func:`module_teardown`.

    This is an alternative to using :class:`ConfiguringTestBase`; the
    two should generally not be mixed in a module. It can also be used
    with Nose's `with_setup` function.
    """
    zope.testing.cleanup.setUp()
    setHooks()
    if configure_events:
        if set_up_packages:
            component.provideHandler(eventtesting.events.append, (None,))
        else:
            eventtesting.setUp()

    _configure(set_up_packages=set_up_packages, features=features)
Beispiel #38
0
def setUp(test):
    testing.setUp(test)
    eventtesting.setUp(test)
Beispiel #39
0
 def setUp(self):
     eventtesting.setUp()
     self.app = self.layer['app']
     self.portal = self.layer['portal']
     self.request = self.layer['request']
     self.util = getUtility(ITokenUtility)
Beispiel #40
0
 def setUp(self):
     super(PlacesIntegrationTestCase, self).setUp()
     eventtesting.setUp()
Beispiel #41
0
    def setUpPloneSite(self, portal):
        applyProfile(portal, 'ftw.downloadtoken:default')

        setRoles(portal, TEST_USER_ID, ['Manager'])
        login(portal, TEST_USER_NAME)
        eventtesting.setUp()
 def setUp(self):
     eventtesting.setUp()
Beispiel #43
0
 def setUp(self):
     super(TestEventHandlers, self).setUp()
     eventtesting.setUp()
     self.setupMailHost()
Beispiel #44
0
 def setUp(self):
     eventtesting.setUp()
Beispiel #45
0
def setUp(test):
    testing.setUp(test)
    eventtesting.setUp(test)
def setUp(self):  # pylint: disable=W0613
    eventtesting.setUp()
Beispiel #47
0
def setUp(test=None):
    testing.setUp()
    eventtesting.setUp()

    provideAdapter(persistentFieldAdapter)
    provideAdapter(choicePersistentFieldAdapter)
Beispiel #48
0
def setUp(test):
    root = setup.placefulSetUp(True)
    test.globs['root'] = root
    eventtesting.setUp()
Beispiel #49
0
def setUp(test):
    testing.setUp()
    eventtesting.setUp()
    container_setup.setUp()
def globalSetUp(test):
    testing.setUp()
    eventtesting.setUp()
    container_setup.setUp()
Beispiel #51
0
def setUp(test=None):
    testing.setUp()
    eventtesting.setUp()

    provideAdapter(persistentFieldAdapter)
    provideAdapter(choicePersistentFieldAdapter)
Beispiel #52
0
 def setUp(self):
     super(TestUtility, self).setUp()
     eventtesting.setUp()
def setUp(self):  # pylint: disable=W0613
    eventtesting.setUp()