From fcb01a5b2b39c6a8e7c132ba647d15773e3725f3 Mon Sep 17 00:00:00 2001 From: hvelarde Date: Thu, 9 Aug 2018 18:04:39 -0300 Subject: [PATCH] Refactor test fixture to load Dexterity content types when available --- .travis.yml | 6 +++--- src/collective/cover/testing.py | 36 ++++++++++----------------------- versions-4.3.x.cfg | 1 - 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5d7e1c8bd..3e37dfd5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ addons: env: matrix: - PLONE_VERSION=4.3 - - PLONE_VERSION=4.3 DEXTERITY_ONLY=true + - PLONE_VERSION=4.3 TEST_EGGS=buildout:test-eggs=plone.app.contenttypes - PLONE_VERSION=4.3 VERSIONS=versions:plone.app.jquery=1.9.2 - PLONE_VERSION=5.1 matrix: @@ -29,8 +29,8 @@ install: - sed -ie "s#test-4.3#test-$PLONE_VERSION#" buildout.cfg - sed -ie "s#versions-4.3#versions-$PLONE_VERSION#" buildout.cfg - python bootstrap.py -- bin/buildout $VERSIONS annotate -- bin/buildout $VERSIONS +- bin/buildout $TEST_EGGS $VERSIONS annotate +- bin/buildout $TEST_EGGS $VERSIONS before_script: - export ROBOT_SELENIUM2LIBRARY_RUN_ON_FAILURE="Capture Page Screenshot" - export DISPLAY=:99.0 diff --git a/src/collective/cover/testing.py b/src/collective/cover/testing.py index 5d007abf7..54e4d2729 100644 --- a/src/collective/cover/testing.py +++ b/src/collective/cover/testing.py @@ -17,7 +17,6 @@ from plone.app.robotframework.testing import AUTOLOGIN_LIBRARY_FIXTURE from plone.app.testing import FunctionalTesting from plone.app.testing import IntegrationTesting -from plone.app.testing import PLONE_FIXTURE from plone.app.testing import PloneSandboxLayer from plone.testing import z2 @@ -29,10 +28,11 @@ try: pkg_resources.get_distribution('plone.app.contenttypes') except pkg_resources.DistributionNotFound: + from plone.app.testing import PLONE_FIXTURE DEXTERITY_ONLY = False else: - # this environment variable is set in .travis.yml test matrix - DEXTERITY_ONLY = os.environ.get('DEXTERITY_ONLY') is not None + from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE as PLONE_FIXTURE + DEXTERITY_ONLY = True try: pkg_resources.get_distribution('Products.PloneFormGen') @@ -116,7 +116,7 @@ def generate_jpeg(width, height): # FIXME: workaround for https://github.com/plone/plone.app.testing/issues/39 # Products.TinyMCE is used only in Plone 4 -if not IS_PLONE_5: +if not DEXTERITY_ONLY: autoform = ('plone.autoform', {'loadZCML': True}) tinymce = ('Products.TinyMCE', {'loadZCML': True}) products = list(PLONE_FIXTURE.products) @@ -129,23 +129,15 @@ class Fixture(PloneSandboxLayer): defaultBases = (PLONE_FIXTURE,) def setUpZope(self, app, configurationContext): - if IS_PLONE_5: - import plone.app.contenttypes - self.loadZCML(package=plone.app.contenttypes) - else: + if not IS_PLONE_5: # needed by plone.app.linkintegrity under Plone 4.x import plone.app.referenceablebehavior self.loadZCML(package=plone.app.referenceablebehavior) - if DEXTERITY_ONLY: - import plone.app.contenttypes - self.loadZCML(package=plone.app.contenttypes) - z2.installProduct(app, 'Products.DateRecurringIndex') - - if HAS_PFG: - import Products.PloneFormGen - self.loadZCML(package=Products.PloneFormGen) - z2.installProduct(app, 'Products.PloneFormGen') + if HAS_PFG: + import Products.PloneFormGen + self.loadZCML(package=Products.PloneFormGen) + z2.installProduct(app, 'Products.PloneFormGen') import collective.cover self.loadZCML(package=collective.cover) @@ -158,14 +150,8 @@ def setUpZope(self, app, configurationContext): manage_addVirtualHostMonster(app, 'virtual_hosting') def setUpPloneSite(self, portal): - if IS_PLONE_5: - self.applyProfile(portal, 'plone.app.contenttypes:default') - else: - if DEXTERITY_ONLY: - self.applyProfile(portal, 'plone.app.contenttypes:default') - - if HAS_PFG: - self.applyProfile(portal, 'Products.PloneFormGen:default') + if HAS_PFG: + self.applyProfile(portal, 'Products.PloneFormGen:default') self.applyProfile(portal, 'collective.cover:default') self.applyProfile(portal, 'collective.cover:testfixture') diff --git a/versions-4.3.x.cfg b/versions-4.3.x.cfg index 3c0f9b7c7..d3e4cee7f 100644 --- a/versions-4.3.x.cfg +++ b/versions-4.3.x.cfg @@ -1,6 +1,5 @@ [buildout] test-eggs = - plone.app.contenttypes plone.app.referenceablebehavior [versions]