I'm developing a PAS plugin for Plone and inside test coverage I'm also testing generated HTML (I'm not using zope.testbrowser or similar, what I need to test is really simple). The problem is that when test runs be call stack is totally different from browser usage (on a real Plone site I replicated the test environment).
Here a piece of the test that fail:
portal = self.layer['portal']
request = self.layer['request']
request.set('ACTUAL_URL', 'http://nohost/plone/folder/subfolder')
request.set('URL', 'http://nohost/plone/folder/subfolder')
login(portal, 'user2')
output = self.folder.subfolder()
Up there subfolder is an ATCT Folder and I'm calling it's default view (folder listing).
Now, the PAS plugin is implementing the checkLocalRolesAllowed method.
def checkLocalRolesAllowed(self, user, object, object_roles):
...
What's is happening:
- using browser the first call to
checkLocalRolesAllowedis done withobject= <ATFolder at subfolder>,user='users2' - running the test the first call to
checkLocalRolesAllowedis done on the portal root with:object= <PloneSite at plone>,user='user2'
On both situations the method is called a lot of additional time (which is normal) but the call order is totally different.
In the test the subfolder context is only the 4rth in the stack order (the Plone site on the first two times, ZCatalog the third).
Starting from the fact that the "good" behavior is the one reproduced by the browser, how can simulate the same behavior on tests? Why calling portal.folder.subfolder() is using the Plone site at the first call?
NB: I tested other combinations like using restrictedTraverse, portal.folder.subfolder.folder_listing(), ... nothing worked.
Aucun commentaire:
Enregistrer un commentaire