Example #1
0
 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)
Example #2
0
 def __init__(self, siteStore):
     """
     Create an L{_AnonymousWebViewer} for browsing a given site store.
     """
     WebViewerHelper.__init__(self,
                              SiteTemplateResolver(siteStore).getDocFactory,
                              lambda: getInstalledThemes(siteStore))
     self._siteStore = siteStore
Example #3
0
 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)
Example #4
0
class TestSiteTemplateResolver(TestCase):
    """
    Tests for L{SiteTemplateResolver}
    """
    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 getDocFactoryWithoutCaching(self, templateName):
        """
        Use C{self.siteResolver} to get a loader for the named template,
        flushing the template cache first in order to make the result reflect
        any changes which in offering or theme availability which may have
        happened since the last call.
        """
        webtheme.theThemeCache.emptyCache()
        return self.siteResolver.getDocFactory(templateName)


    def test_getDocFactory(self):
        """
        L{SiteTemplateResolver.getDocFactory} should return only installed
        themes for its store.
        """
        class FakeTheme(object):
            priority = 0

            def getDocFactory(self, templateName, default=None):
                if templateName == 'shell':
                    return object()
                return default

        self.assertIdentical(self.getDocFactoryWithoutCaching('shell'), None)
        self.offeringTech.installOffering(
            Offering(
                u'an offering', None, [], [], [], [], [FakeTheme()]))
        self.assertNotIdentical(self.getDocFactoryWithoutCaching('shell'), None)
Example #5
0
class TestSiteTemplateResolver(TestCase):
    """
    Tests for L{SiteTemplateResolver}
    """
    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 getDocFactoryWithoutCaching(self, templateName):
        """
        Use C{self.siteResolver} to get a loader for the named template,
        flushing the template cache first in order to make the result reflect
        any changes which in offering or theme availability which may have
        happened since the last call.
        """
        webtheme.theThemeCache.emptyCache()
        return self.siteResolver.getDocFactory(templateName)

    def test_getDocFactory(self):
        """
        L{SiteTemplateResolver.getDocFactory} should return only installed
        themes for its store.
        """
        class FakeTheme(object):
            priority = 0

            def getDocFactory(self, templateName, default=None):
                if templateName == 'shell':
                    return object()
                return default

        self.assertIdentical(self.getDocFactoryWithoutCaching('shell'), None)
        self.offeringTech.installOffering(
            Offering(u'an offering', None, [], [], [], [], [FakeTheme()]))
        self.assertNotIdentical(self.getDocFactoryWithoutCaching('shell'),
                                None)
Example #6
0
 def getDocFactory(self, fragmentName, default=None):
     resolver = SiteTemplateResolver(self.store)
     return resolver.getDocFactory(fragmentName, default)
Example #7
0
 def getDocFactory(self, fragmentName, default=None):
     resolver = SiteTemplateResolver(self.store)
     return resolver.getDocFactory(fragmentName, default)