vendredi 19 février 2016

Automatically install default content types in tests on Plone 5

I've been trying to add compatibility with Plone 5 in some of our add-ons and I found a pattern that I want to avoid: seem that I have to manually install default content types on test fixture like this:

...
PLONE_VERSION = api.env.plone_version()


class Fixture(PloneSandboxLayer):

    defaultBases = (PLONE_FIXTURE,)

    def setUpZope(self, app, configurationContext):
        if PLONE_VERSION >= '5.0':
            import plone.app.contenttypes
            self.loadZCML(package=plone.app.contenttypes)
        ...

    def setUpPloneSite(self, portal):
        if PLONE_VERSION >= '5.0':
            self.applyProfile(portal, 'plone.app.contenttypes:default')
        ...

FIXTURE = Fixture()
...

Is there any way to avoid this?

Aucun commentaire:

Enregistrer un commentaire