Ejemplo n.º 1
0
    def setUp(self):
        if self._is_base_test() or not self.condition():
            return

        self.validate()
        self.resultdir = self.get_test_result_directory()

        from ftw.book import tests
        self.booksdir = os.path.join(os.path.dirname(tests.__file__), 'books')

        request = self.layer['portal'].REQUEST
        mark_layer(None, Dummy(request=request))
        provide_request_layer(request, IWithinBookLayer)
        provide_request_layer(request, self.book_layout_layer)

        # configure language to german, since the test book is german
        tool = getToolByName(self.layer['portal'], "portal_languages")
        tool.manage_setLanguageSettings('de', ['de'])

        self.install_profiles()

        expectation = self.get_absolute_path(self.expected_result)
        filenamebase, _ext = os.path.splitext(os.path.basename(expectation))
        build_dir = os.path.join(self.resultdir, '%s_build' % filenamebase)
        self.config = PDFGeneratorTestConfig(build_dir)
        self.layer['portal'].getSiteManager().registerUtility(self.config)
Ejemplo n.º 2
0
    def setUp(self):
        if self._is_base_test() or not self.condition():
            return

        self.validate()
        self.resultdir = self.get_test_result_directory()

        from ftw.book import tests
        self.booksdir = os.path.join(os.path.dirname(tests.__file__), 'books')

        request = self.layer['portal'].REQUEST
        mark_layer(None, Dummy(request=request))
        provide_request_layer(request, IWithinBookLayer)
        provide_request_layer(request, self.book_layout_layer)

        # configure language to german, since the test book is german
        tool = getToolByName(self.layer['portal'], "portal_languages")
        tool.manage_setLanguageSettings('de', ['de'])

        self.install_profiles()

        expectation = self.get_absolute_path(self.expected_result)
        filenamebase, _ext = os.path.splitext(os.path.basename(expectation))
        build_dir = os.path.join(self.resultdir, '%s_build' % filenamebase)
        self.config = PDFGeneratorTestConfig(build_dir)
        self.layer['portal'].getSiteManager().registerUtility(self.config)
Ejemplo n.º 3
0
def mark_layer(site, event):
    base.mark_layer(site, event)
    request = event.request
    registry = component.getUtility(IRegistry)
    settings = registry.forInterface(interfaces.IThemeSettings)
    if request.get('BASE1') == settings.domain:
        ifaces = [interfaces.IThemingLayer] + list(interface.directlyProvidedBy(request))
        interface.directlyProvides(request, *ifaces)
 def afterSetUp(self):
     super(TestSetup, self).afterSetUp()
     # restrictedTraverse does not trigger BeforeTraverseEvent...
     #    so do it manually.
     # TODO: would be better to access these resources with a full
     #       publishing request.
     mark_layer(self.portal, BeforeTraverseEvent(self.portal,
                                                 self.portal.REQUEST))
Ejemplo n.º 5
0
 def afterSetUp(self):
     # due to some reason plone.browserlayer is not marking REQUEST
     # with installed products layer interfaces
     # so I'm doing it manually here
     class DummyEvent(object):
         def __init__(self, request):
             self.request = request
     mark_layer(self.portal, DummyEvent(self.portal.REQUEST))
Ejemplo n.º 6
0
 def afterSetUp(self):
     # due to some reason plone.browserlayer is not marking REQUEST
     # with installed products layer interfaces
     # so I'm doing it manually here 
     class DummyEvent(object):
         def __init__(self, request):
             self.request = request
     mark_layer(self.portal, DummyEvent(self.portal.REQUEST))
Ejemplo n.º 7
0
def mark_layer(site, event):
    base.mark_layer(site, event)
    request = event.request
    registry = component.getUtility(IRegistry)
    settings = registry.forInterface(interfaces.IThemeSettings)
    if request.get('BASE1') == settings.domain:
        ifaces = [interfaces.IBrowserLayer] + list(
            interface.directlyProvidedBy(request))
        interface.directlyProvides(request, *ifaces)
Ejemplo n.º 8
0
    def afterSetUp(self):
        self.types = {
            'WorkspaceContainer': None,
            'SandboxContainer': None,
            'ExposureContainer': None,
            'Sandbox': None,
            'Exposure': 'pmr2_exposure_workflow',
            'Workspace': 'pmr2_workspace_workflow',
        }

        self.addProfile('pmr2.app:default')
        event = BeforeTraverseEvent(self.portal, self.portal.REQUEST)
        mark_layer(self.portal, event)
Ejemplo n.º 9
0
 def setUp(self):
     super(IntegrationTestCase, self).setUp()
     self.portal = self.layer['portal']
     ptesting.setRoles(self.portal, ptesting.TEST_USER_ID, ['Manager'])
     ptesting.login(self.portal, ptesting.TEST_USER_NAME)
     languages = ['en', 'fr', 'nl']
     defaultLanguage = 'en'
     planguages = self.portal.portal_languages
     planguages.manage_setLanguageSettings(defaultLanguage, languages)
     self.portal.invokeFactory('Folder', 'dossier')
     self.folder = self.portal['dossier']
     self.folder.setLanguage('fr')
     self.folder.reindexObject()
     self.portal.portal_properties.site_properties.enable_sitemap = True
     self.request = self.layer['request']
     mark_layer(self.portal, self)
Ejemplo n.º 10
0
def mark_layer(site, event):
    """
    Support re-marking an already marked request.
    """
    if hasattr(event.request, "_plonebrowserlayer_"):
        del event.request._plonebrowserlayer_
    return layer.mark_layer(site, event)
Ejemplo n.º 11
0
def mark_layer(site, event):
    """
    Support re-marking an already marked request.
    """
    if hasattr(event.request, "_plonebrowserlayer_"):
        del event.request._plonebrowserlayer_
    return layer.mark_layer(site, event)
Ejemplo n.º 12
0
    def setUp(self):
        # Stack the component registry
        self["configurationContext"] = zca.stackConfigurationContext(self.get("configurationContext"))

        # Stack the database
        self["zodbDB"] = zodb.stackDemoStorage(self.get("zodbDB"), name="ftw.book:examplecontent")

        # Register and apply the example content GS profile
        import ftw.book.tests

        xmlconfig.file("examplecontent.zcml", ftw.book.tests, context=self["configurationContext"])

        with ploneSite() as portal:
            request = portal.REQUEST
            mark_layer(None, Dummy(request=request))
            provide_request_layer(request, IWithinBookLayer)
            provide_request_layer(request, IDefaultBookLayoutSelectionLayer)

            applyProfile(portal, "ftw.book.tests:examplecontent")
Ejemplo n.º 13
0
    def setUp(self):
        # Stack the component registry
        self['configurationContext'] = zca.stackConfigurationContext(
            self.get('configurationContext'))

        # Stack the database
        self['zodbDB'] = zodb.stackDemoStorage(self.get('zodbDB'),
                                               name='ftw.book:examplecontent')

        # Register and apply the example content GS profile
        import ftw.book.tests
        xmlconfig.file('examplecontent.zcml',
                       ftw.book.tests,
                       context=self['configurationContext'])

        with ploneSite() as portal:
            request = portal.REQUEST
            mark_layer(None, Dummy(request=request))
            provide_request_layer(request, IWithinBookLayer)
            provide_request_layer(request, IDefaultBookLayoutSelectionLayer)

            applyProfile(portal, 'ftw.book.tests:examplecontent')
Ejemplo n.º 14
0
    def setUp(self):
        self.portal = self.layer['portal']
        self.request = self.layer['request']
        self.subsite = self.portal.get('foo').get('subsite')

        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        login(self.portal, TEST_USER_NAME)

        self.tree = self.portal.get('topics')
        self.node = self.tree.get('manufacturing')
        self.subnode = self.node.get('agile-manufacturing')
        self.topic_technology = self.tree.get('technology')

        self.subsite_tree = self.subsite.get('topics')
        self.subsite_node = self.subsite_tree.get('manufacturing')

        self.browser = Browser(self.layer['app'])
        self.browser.addHeader('Authorization', 'Basic %s:%s' % (
            TEST_USER_NAME, TEST_USER_PASSWORD,))
        self.browser.handleErrors = False

        mark_layer(None, Dummy(request=self.request))
Ejemplo n.º 15
0
 def setUp(self):
     self.portal = self.layer['portal']
     self.request = self.layer['request']
     event = BeforeTraverseEvent(self.portal, self.request)
     mark_layer(self.portal, event)
Ejemplo n.º 16
0
 def afterSetUp(self):
     self.addProfile("pmr2.z3cform:default")
     event = BeforeTraverseEvent(self.portal, self.portal.REQUEST)
     mark_layer(self.portal, event)
Ejemplo n.º 17
0
 def setUp(self):
     self.portal = self.layer['portal']
     self.request = self.layer['request']
     event = BeforeTraverseEvent(self.portal, self.request)
     mark_layer(self.portal, event)
Ejemplo n.º 18
0
 def setUp(self):
     self.portal = self.layer['portal']
     self.request = self.layer['request']
     setRoles(self.portal, TEST_USER_ID, ['Manager'])
     mark_layer(self.portal,
                BeforeTraverseEvent(self.portal, self.request))
Ejemplo n.º 19
0
 def setUp(self):
     portal = self.layer['portal']
     request = self.layer['request']
     applyProfile(portal, 'ftw.solr:default')
     mark_layer(portal, BeforeTraverseEvent(portal, request))
     transaction.commit()
Ejemplo n.º 20
0
 def setUp(self):
     self.portal = self.layer['portal']
     self.request = self.layer['request']
     setRoles(self.portal, TEST_USER_ID, ['Manager'])
     mark_layer(self.portal, BeforeTraverseEvent(self.portal, self.request))
Ejemplo n.º 21
0
 def markLayer(self):
     # Helper method to trigger the mark layer event.
     event = BeforeTraverseEvent(self.portal, self.portal.REQUEST)
     mark_layer(self.portal, event)
Ejemplo n.º 22
0
 def afterSetUp(self):
     self.addProfile('pmr2.captcha:default')
     event = BeforeTraverseEvent(self.portal, self.portal.REQUEST)
     mark_layer(self.portal, event)
Ejemplo n.º 23
0
 def setUp(self):
     portal = self.layer['portal']
     request = self.layer['request']
     applyProfile(portal, 'ftw.solr:default')
     mark_layer(portal, BeforeTraverseEvent(portal, request))
     transaction.commit()
Ejemplo n.º 24
0
 def afterSetUp(self):
     import plone.app.z3cform.tests
     zcml.load_config('testing.zcml', plone.app.z3cform.tests)
     self.addProfile('plone.app.z3cform:default')
     event = BeforeTraverseEvent(self.portal, self.portal.REQUEST)
     mark_layer(self.portal, event)
Ejemplo n.º 25
0
 def afterSetUp(self):
     import plone.app.z3cform.tests
     zcml.load_config('testing.zcml', plone.app.z3cform.tests)
     self.addProfile('plone.app.z3cform:default')
     event = BeforeTraverseEvent(self.portal, self.portal.REQUEST)
     mark_layer(self.portal, event)