Skip to content

Commit

Permalink
Refactor test fixture to load Dexterity content types when available
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Aug 9, 2018
1 parent 3f3bbbd commit fcb01a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
36 changes: 11 additions & 25 deletions src/collective/cover/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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')
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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')
Expand Down
1 change: 0 additions & 1 deletion versions-4.3.x.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[buildout]
test-eggs =
plone.app.contenttypes
plone.app.referenceablebehavior

[versions]
Expand Down

0 comments on commit fcb01a5

Please sign in to comment.