[Zope-CMF] Testing skin scripts and templates using ZopeTestCase.Functional
Hi again :) I'm trying to use CMFTestCase along with ZopeTestCase.Functional to test my skin scripts. But how do I get them set up properly? Anybody have working examples of this? I wondered if there might be some in the Plone test suites but if so I didn't find any. Example that fails because "document_view" is 404: class TestUI(CMFTestCase.CMFTestCase, ZopeTestCase.FunctionalTestCase, ): """Test the skin scripts and templates. """ def getPortal(self): # Set up a CMF site. setupCMFSite(app=self.app) return getattr(self.app, CMFTestCase.portal_name) def afterSetUp(self): self.basic_auth = '%s:%s' % (user_name, user_password) self.setRoles(['Manager', 'Member']) # Add a folder and a doc. self.portal.invokeFactory(type_name='Folder', id='folder1') self.fol1 = self.portal.folder1 data = 'Testing ZSyncer Tool, blah blah blah' self.fol1.invokeFactory('Document', 'test_doc1', title='nunya bizness', text=data) self.doc1 = self.fol1.test_doc1 def test_DocView(self): url = self.doc1.absolute_url_path() import pdb; pdb.set_trace() response = self.publish(url, self.basic_auth) Some stepping around with pdb reveals this: (Pdb) n > /zope/ZopeSoftwareHome/lib/python/ZPublisher/Publish.py(101)publish() -> request, bind=1) (Pdb) n NotFound: 'document_view' -- Paul Winkler http://www.slinkp.com ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
Re: [Zope-CMF] Testing skin scripts and templates using ZopeTestCase.Functional
def test_DocView(self): url = self.doc1.absolute_url_path() import pdb; pdb.set_trace() response = self.publish(url, self.basic_auth) Some stepping around with pdb reveals this: (Pdb) n /zope/ZopeSoftwareHome/lib/python/ZPublisher/Publish.py(101)publish() -> request, bind=1) (Pdb) n NotFound: 'document_view' The machinery doesn't know which skin is selected I presume. You can "force" it by calling "changeSkin" on the skinnable object manager (the portal is one) to select a skin path as set up in the skins tool: self.portal.changeSkin('Nouvelle') jens ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
Re: [Zope-CMF] Testing skin scripts and templates using ZopeTestCase.Functional
Jens Vagelpohl said: >> def test_DocView(self): >> url = self.doc1.absolute_url_path() >> import pdb; pdb.set_trace() >> response = self.publish(url, self.basic_auth) >> >> >> Some stepping around with pdb reveals this: >> >> (Pdb) n >> >>> /zope/ZopeSoftwareHome/lib/python/ZPublisher/Publish.py(101)publish() >>> >> -> request, bind=1) >> (Pdb) n >> NotFound: 'document_view' > > The machinery doesn't know which skin is selected I presume. You can > "force" it by calling "changeSkin" on the skinnable object manager > (the portal is one) to select a skin path as set up in the skins tool: > > self.portal.changeSkin('Nouvelle') That may well be necessary, but it's evidently not sufficient :-) Any other ideas? Meanwhile, it's more time in the debugger for me... Hmm, now that I think about it, I seem to recall that skin objects aren't acquired when I'm poking around in "zopectl debug" either. Presumably it's the same problem. I had a look at the tests for CMFCore and CMFDefault, but there don't seem to be any tests for SkinnableObjectManager at all. Ouch! -- Paul Winkler http://www.slinkp.com ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
Re: [Zope-CMF] Testing skin scripts and templates using ZopeTestCase.Functional
On 5 Oct 2005, at 23:07, Paul Winkler wrote: -> request, bind=1) (Pdb) n NotFound: 'document_view' The machinery doesn't know which skin is selected I presume. You can "force" it by calling "changeSkin" on the skinnable object manager (the portal is one) to select a skin path as set up in the skins tool: self.portal.changeSkin('Nouvelle') That may well be necessary, but it's evidently not sufficient :-) Any other ideas? Meanwhile, it's more time in the debugger for me... Hmm, now that I think about it, I seem to recall that skin objects aren't acquired when I'm poking around in "zopectl debug" either. Presumably it's the same problem. This specific condition (skin objects not found when in zopectl debug or when testing) has *always* been remedied for me by calling changeSkin... jens ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
Re: [Zope-CMF] Testing skin scripts and templates using ZopeTestCase.Functional
Jens Vagelpohl said: >>> The machinery doesn't know which skin is selected I presume. You can >>> "force" it by calling "changeSkin" on the skinnable object manager >>> (the portal is one) to select a skin path as set up in the skins >>> tool: >>> >>> self.portal.changeSkin('Nouvelle') >>> >> >> That may well be necessary, but it's evidently not sufficient :-) Any >> other ideas? Meanwhile, it's more time in the debugger for me... Hmm, >> now that I think about it, I seem to recall that skin objects aren't >> acquired when I'm poking around in "zopectl debug" either. Presumably >> it's the same problem. > > This specific condition (skin objects not found when in zopectl debug > or when testing) has *always* been remedied for me by calling > changeSkin... Aha! I just confirmed that it works as you say in zopectl debug. (You do have to first make sure that the portal has a REQUEST attribute.) I had a closer look at the setup done by CMFTestCase.setupCMFSite() and it explicitly avoids setting up the default skins as an optimization, and provides a function you can call if you want 'em. Problem solved!! Thanks for the hint. -- Paul Winkler http://www.slinkp.com ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
Re: [Zope-CMF] Testing skin scripts and templates using ZopeTestCase.Functional
Paul Winkler wrote: Hi again :) I'm trying to use CMFTestCase along with ZopeTestCase.Functional to test my skin scripts. But how do I get them set up properly? Anybody have working examples of this? I wondered if there might be some in the Plone test suites but if so I didn't find any. Example that fails because "document_view" is 404: class TestUI(CMFTestCase.CMFTestCase, ZopeTestCase.FunctionalTestCase, ): """Test the skin scripts and templates. """ def getPortal(self): # Set up a CMF site. setupCMFSite(app=self.app) return getattr(self.app, CMFTestCase.portal_name) def afterSetUp(self): self.basic_auth = '%s:%s' % (user_name, user_password) self.setRoles(['Manager', 'Member']) # Add a folder and a doc. self.portal.invokeFactory(type_name='Folder', id='folder1') self.fol1 = self.portal.folder1 data = 'Testing ZSyncer Tool, blah blah blah' self.fol1.invokeFactory('Document', 'test_doc1', title='nunya bizness', text=data) self.doc1 = self.fol1.test_doc1 def test_DocView(self): url = self.doc1.absolute_url_path() import pdb; pdb.set_trace() response = self.publish(url, self.basic_auth) Some stepping around with pdb reveals this: (Pdb) n /zope/ZopeSoftwareHome/lib/python/ZPublisher/Publish.py(101)publish() -> request, bind=1) (Pdb) n NotFound: 'document_view' Maybe adding the following in afterSetUp() will help. self._refreshSkinData() -Tom ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
Re: [Zope-CMF] Testing skin scripts and templates using ZopeTestCase.Functional
Paul Winkler wrote: Aha! I just confirmed that it works as you say in zopectl debug. (You do have to first make sure that the portal has a REQUEST attribute.) Yeah, I believe the canonical way is: from Testing.makerequest import makerequest portal = makerequest(self.portal) portal.changeSkin('Nouvelle') cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests