[Product-Developers] How to deal with different url structure in testbrowser? (no VirtualHostBase)
René Pijlman
reneOnLists at applinet.nl
Tue Dec 29 21:04:14 UTC 2009
I'm developing a product for Plone 3.3 that transforms url's in the view
of my content type, following Martin's book (which is now the most worn
out book on my shelf :-). The unit tests work fine, but a functional
test in zope.testbrowser failed. It turns out this is caused by the
url's of pages in the testbrowser.
The test begins with the ususal:
>>> from Products.Five.testbrowser import Browser
>>> browser = Browser()
>>> portal_url = self.portal.absolute_url()
Then it opens portal_url, adds folder 'ham', opens that folder and adds
a page 'spam'. In the test runner (bin/instance test -s my.package) this
results in the url:
(Pdb) print browser.url
http://nohost/plone/ham/spam
^^^^^^
When the site is accessed through Apache and VirtualHostBase, the same
page would have the url:
http://myhost/ham/spam
The difference is the extra '/plone' in the test runner, for the plone
site object in Zope's root. This causes my test for a root-relative link
to fail:
>>> '<a href="/eggs">' in browser.contents
True
... since in the test runner that link has become:
(Pdb) print browser.contents[15650:15670]
<a href="/plone/eggs">
Is there a way to have the test runner use VirtualHostBase, and get urls
that are the same as with interactive use through Apache and
VirtualHostBase?
Or is the custom solution to write the tests as if using Zope directly,
without Apache and VirtualHostBase?
--
René
http://www.applinet.nl
More information about the Product-Developers
mailing list