Hi folks!
I'm still stuck getting a 10k line Plone 4 project moved to Plone 5, and at this rate I probably should've just rewritten everything to use Dexterity
In any case, I'm at the point where, through the web, I can create Archetypes-based types using the "Add new…" menu. But I'd also like to get the functional tests to work, and that's where things get wonky. My README.rst
looks something like this:
>>> browser.open(portal_url)
>>> link = browser.getLink(id='my-type')
>>> 'createObject?type_name=My+Type' in link.url
True
>>> link.click()
It's at the link.click()
that the 404 suddenly occurs.
Now I assume the setup of the functional test requires some extra "gymnastics" in Plone 5. The question is: what?
So far, testing.py
does:
class MyAddOn(PloneSandboxLayer):
defaultBases = (PLONE_FIXTURE,)
def setUpZope(self, app, configurationContext):
import my.addon
self.loadZCML(package=my.addon)
z2.installProduct(app, 'my.addon')
def setUpPloneSite(self, portal):
self.applyProfile(portal, 'my.addon:default')
def tearDownZope(self, app):
z2.uninstallProduct(app, 'my.addon')
MY_ADDON_FIXTURE = MyAddOn()
MY_ADDON_FIXTURE_FUNCTIONAL_TESTING = FunctionalTesting(
bases = (MY_ADDON_FIXTURE,),
name = 'MyAddOn:Functional'
)
And test_doctest.py
does the usual as well:
optionFlags = (
doctest.ELLIPSIS |
doctest.NORMALIZE_WHITESPACE |
doctest.REPORT_ONLY_FIRST_FAILURE
)
def test_suite():
return unittest.TestSuite([
layered(doctest.DocFileSuite('README.rst',
package='my.addon',
optionflags=optionFlags),
LAYER),
])
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
Finally, the preamble to README.rst
:
app = layer['app']
from plone.testing.z2 import Browser
from plone.app.testing import SITE_OWNER_NAME, SITE_OWNER_PASSWORD
browser = Browser(app)
browser.handleErrors = False
browser.addHeader('Authorization', 'Basic %s:%s' % (SITE_OWNER_NAME, SITE_OWNER_PASSWORD))
portal = layer['portal']
portal_url = portal.absolute_url()
Leading ultimately to:
>>> browser.open(portal_url)
>>> link = browser.getLink(id='my-type')
>>> 'createObject?type_name=My+Type' in link.url
True
>>> link.click()
And the 404 at the link.click()
. Any hints?
Again it works fine operationally. But my management is in love with Jenkins. Seriously. In love. It's not healthy.