def setUp(self): """ Create a L{Store} with a fake L{IOfferingTechnician} powerup which allows fine-grained control of template name resolution. """ self.offeringTech = FakeOfferingTechnician() self.store = Store() self.store.inMemoryPowerUp(self.offeringTech, IOfferingTechnician) self.siteResolver = SiteTemplateResolver(self.store)
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))])