Example #1
0
    def test_headRenderer(self):
        """
        The I{head} renderer gets the head section for each installed theme by
        calling their C{head} method with the request being rendered and adds
        the result to the tag it is passed.
        """
        headCalls = []
        customHead = object()

        class CustomHeadTheme(object):
            priority = 0
            themeName = "custom"

            def head(self, request, site):
                headCalls.append((request, site))
                return customHead

            def getDocFactory(self, name, default):
                return default

        tech = FakeOfferingTechnician()
        tech.installOffering(
            Offering(
                name=u"fake",
                description=u"",
                siteRequirements=[],
                appPowerups=[],
                installablePowerups=[],
                loginInterfaces=[],
                themes=[CustomHeadTheme()],
            )
        )
        self.siteStore.inMemoryPowerUp(tech, IOfferingTechnician)

        # Flush the cache, which is global, else the above fake-out is
        # completely ignored.
        theThemeCache.emptyCache()

        page = self.createPage(self.username)
        tag = div()
        ctx = context.WebContext(tag=tag)
        request = FakeRequest()
        ctx.remember(request, inevow.IRequest)
        result = page.render_head(ctx, None)
        self.assertEqual(result.tagName, "div")
        self.assertEqual(result.attributes, {})
        self.assertIn(customHead, result.children)
        self.assertEqual(headCalls, [(request, ISiteURLGenerator(self.siteStore))])
Example #2
0
    def test_getDocFactory(self):
        """
        L{PrivateApplication.getDocFactory} finds a document factory for
        the specified template name from among the installed themes.
        """
        # Get something from the Mantissa theme
        self.assertNotIdentical(self.privapp.getDocFactory('shell'), None)

        # Get rid of the Mantissa offering and make sure the template is no
        # longer found.
        self.siteStore.query(InstalledOffering).deleteFromStore()

        # And flush the cache. :/ -exarkun
        theThemeCache.emptyCache()

        self.assertIdentical(self.privapp.getDocFactory('shell'), None)
Example #3
0
    def test_headRenderer(self):
        """
        The I{head} renderer gets the head section for each installed theme by
        calling their C{head} method with the request being rendered and adds
        the result to the tag it is passed.
        """
        headCalls = []
        customHead = object()

        class CustomHeadTheme(object):
            priority = 0
            themeName = "custom"

            def head(self, request, site):
                headCalls.append((request, site))
                return customHead

            def getDocFactory(self, name, default):
                return default

        tech = FakeOfferingTechnician()
        tech.installOffering(
            Offering(name=u'fake',
                     description=u'',
                     siteRequirements=[],
                     appPowerups=[],
                     installablePowerups=[],
                     loginInterfaces=[],
                     themes=[CustomHeadTheme()]))
        self.siteStore.inMemoryPowerUp(tech, IOfferingTechnician)

        # Flush the cache, which is global, else the above fake-out is
        # completely ignored.
        theThemeCache.emptyCache()

        page = self.createPage(self.username)
        tag = div()
        ctx = context.WebContext(tag=tag)
        request = FakeRequest()
        ctx.remember(request, inevow.IRequest)
        result = page.render_head(ctx, None)
        self.assertEqual(result.tagName, 'div')
        self.assertEqual(result.attributes, {})
        self.assertIn(customHead, result.children)
        self.assertEqual(headCalls,
                         [(request, ISiteURLGenerator(self.siteStore))])