Ejemplo n.º 1
0
 class TestSkinnableObjectManager(SkinnableObjectManager):
     tool = SkinsTool()
     sm = getSiteManager()
     sm.registerUtility(tool, ISkinsTool)
     # This is needed otherwise REQUEST is the string
     # '<Special Object Used to Force Acquisition>'
     REQUEST = None
Ejemplo n.º 2
0
    def setUp(self):
        from Products.CMFCore import DirectoryView
        from Products.CMFCore.SkinsTool import SkinsTool

        _DVRegistrySetup.setUp(self)
        self._obj = SkinsTool()
        self._BODY = _SKINSTOOL_BODY
Ejemplo n.º 3
0
 class TestSkinnableObjectManager(SkinnableObjectManager):
     tool = SkinsTool()
     # This is needed otherwise REQUEST is the string
     # '<Special Object Used to Force Acquisition>'
     REQUEST = None 
     def getSkinsFolderName(self):
         '''tool'''
         return 'tool'
Ejemplo n.º 4
0
    def test_add_invalid_path(self):
        tool = SkinsTool()

        # We start out with no wkin selections
        self.assertEquals(len(tool.getSkinSelections()), 0)

        # Add a skin selection with an invalid path element
        paths = 'foo, bar, .svn'
        tool.addSkinSelection('fooskin', paths)

        # Make sure the skin selection exists
        paths = tool.getSkinPath('fooskin')
        self.failIf(paths is None)

        # Test for the contents
        self.failIf(paths.find('foo') == -1)
        self.failIf(paths.find('bar') == -1)
        self.failUnless(paths.find('.svn') == -1)
Ejemplo n.º 5
0
    def setUp(self):
        import Products.CMFCore.exportimport
        from Products.CMFCore import DirectoryView
        from Products.CMFCore.SkinsTool import SkinsTool

        BodyAdapterTestCase.setUp(self)
        _DVRegistrySetup.setUp(self)
        zcml.load_config('configure.zcml', Products.CMFCore.exportimport)

        self._obj = SkinsTool()
        self._BODY = _SKINSTOOL_BODY
Ejemplo n.º 6
0
    def test_getCurrentSkinName(self):
        from Products.CMFCore.interfaces import ISkinsTool
        from Products.CMFCore.SkinsTool import SkinsTool

        som = self._makeOne()

        pathA = ('foo, bar')
        pathB = ('bar, foo')

        stool = SkinsTool()
        stool.addSkinSelection('skinA', pathA)
        stool.addSkinSelection('skinB', pathB)
        stool.manage_properties(default_skin='skinA')
        getSiteManager().registerUtility(stool, ISkinsTool)

        # Expect the default skin name to be returned
        self.assertTrue(som.getCurrentSkinName() == 'skinA')

        # after a changeSkin the new skin name should be returned
        som.changeSkin('skinB', som.REQUEST)
        self.assertTrue(som.getCurrentSkinName() == 'skinB')
Ejemplo n.º 7
0
    def test_getSkinNameFromRequest(self):
        from Products.CMFCore.interfaces import ISkinsTool
        from Products.CMFCore.SkinsTool import SkinsTool
        som = self._makeOne()

        stool = SkinsTool()
        getSiteManager().registerUtility(stool, ISkinsTool)

        #by default, no special sinname is set
        self.assertEqual(som.getSkinNameFromRequest(self.REQUEST), None)

        #provide a value
        self.REQUEST['portal_skin'] = 'skinA'
        self.assertEqual(som.getSkinNameFromRequest(self.REQUEST), 'skinA')

        # test for non-existend http header variable
        # see https://dev.plone.org/ticket/10071
        stool.request_varname = 'HTTP_SKIN_NAME'
        self.assertEqual(som.getSkinNameFromRequest(self.REQUEST), None)

        # test for http header variable
        self.REQUEST['HTTP_SKIN_NAME'] = 'skinB'
        self.assertEqual(som.getSkinNameFromRequest(self.REQUEST), 'skinB')
Ejemplo n.º 8
0
    def test_add_invalid_path(self):
        tool = SkinsTool()

        # We start out with no wkin selections
        self.assertEquals(len(tool.getSkinSelections()), 0)

        # Add a skin selection with an invalid path element
        paths = 'foo, bar, .svn'
        tool.addSkinSelection('fooskin', paths)

        # Make sure the skin selection exists
        paths = tool.getSkinPath('fooskin')
        self.failIf(paths is None)

        # Test for the contents
        self.failIf(paths.find('foo') == -1)
        self.failIf(paths.find('bar') == -1)
        self.failUnless(paths.find('.svn') == -1)
Ejemplo n.º 9
0
    def test_getCurrentSkinName(self):
        from Products.CMFCore.interfaces import ISkinsTool
        from Products.CMFCore.SkinsTool import SkinsTool

        som = self._makeOne()

        pathA = ('foo, bar')
        pathB = ('bar, foo')

        stool = SkinsTool()
        stool.addSkinSelection('skinA', pathA)
        stool.addSkinSelection('skinB', pathB)
        stool.manage_properties(default_skin='skinA')
        getSiteManager().registerUtility(stool, ISkinsTool)

        # Expect the default skin name to be returned
        self.assertTrue(som.getCurrentSkinName() == 'skinA')

        # after a changeSkin the new skin name should be returned
        som.changeSkin('skinB', som.REQUEST)
        self.assertTrue(som.getCurrentSkinName() == 'skinB')
Ejemplo n.º 10
0
    def _makeOne(self, *args, **kw):
        from Products.CMFCore.SkinsTool import SkinsTool

        return SkinsTool(*args, **kw)