ploneplone-5.x

How to access programmatically the list of resources in Plone 5 registry


I'm writing tests for some packages and I need to verify if some static resources are being registered correctly.

Before Plone 5 I can do that just by accessing the resource registries like this:

self.portal.portal_javascripts.getResourceIds()
self.portal.portal_css.getResourceIds()

How can I accomplish that task in Plone 5?


Solution

  • As there is no easy way to accomplish this task and the proposed solution adds more than 10 lines of code, I would say that this test must just be skipped in Plone 5:

    IS_PLONE_5 = api.env.plone_version().startswith('5')
    
    @unittest.skipIf(IS_PLONE_5, 'No easy way to test this under Plone 5')
    def test_cssregistry(self):
        resource_ids = self.portal.portal_css.getResourceIds()
        self.assertIn(CSS, resource_ids)