Skip to content

Commit

Permalink
Merge pull request #8 from collective/gforcada-plone-5.x-compat
Browse files Browse the repository at this point in the history
Add Plone 5.x compat
  • Loading branch information
gforcada committed Aug 18, 2017
2 parents b4f0216 + fe5f39c commit 064a60b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
6 changes: 0 additions & 6 deletions .travis.yml
Expand Up @@ -9,12 +9,6 @@ env:
- PLONE_VERSION=4.3
- PLONE_VERSION=5.0
- PLONE_VERSION=5.1
matrix:
allow_failures:
- python: 2.7
env: PLONE_VERSION=5.0
- python: 2.7
env: PLONE_VERSION=5.1
install:
- sed -ie "s#test-4.3#test-$PLONE_VERSION#" buildout.cfg
- pip install -r requirements.txt
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -20,6 +20,9 @@ Changelog
- Minor cleanups here and there.
[gforcada]

- Add Plone 5 compatibility.
[gforcada]

1.0 (2014-05-04)
----------------

Expand Down
4 changes: 3 additions & 1 deletion setup.py
Expand Up @@ -18,8 +18,10 @@
# Get more strings from
# http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Framework :: Plone :: 4.3',
'Framework :: Plone',
'Framework :: Plone :: 4.3',
'Framework :: Plone :: 5.0',
'Framework :: Plone :: 5.1',
'Programming Language :: Python :: 2 :: Only',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python',
Expand Down
10 changes: 10 additions & 0 deletions wildcard/lockdown/testing.py
Expand Up @@ -9,19 +9,29 @@
from plone.app.testing.layers import IntegrationTesting
from zope.configuration import xmlconfig
from plone.testing import z2
from plone import api


IS_PLONE_5 = api.env.plone_version().startswith('5')


class Lockdown(PloneSandboxLayer):
defaultBases = (PLONE_FIXTURE,)

def setUpZope(self, app, configurationContext):
if IS_PLONE_5:
import plone.app.contenttypes
self.loadZCML(package=plone.app.contenttypes)
# load ZCML
import wildcard.lockdown
xmlconfig.file('configure.zcml', wildcard.lockdown,
context=configurationContext)
z2.installProduct(app, 'wildcard.lockdown')

def setUpPloneSite(self, portal):
if IS_PLONE_5:
applyProfile(portal, 'plone.app.contenttypes:default')

# install into the Plone site
applyProfile(portal, 'wildcard.lockdown:default')
setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
Expand Down
23 changes: 14 additions & 9 deletions wildcard/lockdown/tests/test_lockdown.py
Expand Up @@ -7,6 +7,12 @@
import transaction
import unittest
from wildcard.lockdown.testing import Lockdown_FUNCTIONAL_TESTING
from wildcard.lockdown.testing import IS_PLONE_5


title_filed = 'title'
if IS_PLONE_5:
title_filed = 'form.widgets.IDublinCore.title'


class TestLockdown(unittest.TestCase):
Expand Down Expand Up @@ -44,15 +50,18 @@ def disableConditions(self):
self._settings.activated = set(())
transaction.commit()

def changeTitle(self, url, newtitle):
self.browser.open(url + '/edit')
self.browser.getControl(name=title_filed).value = newtitle
self.browser.getControl('Save').click()

def test_prevents_committing_to_database(self):
self.activateCondition()
baseurl = self.portal_url + '/testpage'
newtitle = "EDITED TITLE"
self.browser.open(baseurl)
self.assertTrue(newtitle not in self.browser.contents)
self.browser.open(baseurl + '/edit')
self.browser.getControl(name='title').value = newtitle
self.browser.getControl(name='form.button.save').click()
self.changeTitle(baseurl, newtitle)
self.assertTrue(newtitle not in self.browser.contents)

def test_allows_writing_to_database(self):
Expand All @@ -61,9 +70,7 @@ def test_allows_writing_to_database(self):
newtitle = "EDITED TITLE"
self.browser.open(baseurl)
self.assertTrue(newtitle not in self.browser.contents)
self.browser.open(baseurl + '/edit')
self.browser.getControl(name='title').value = newtitle
self.browser.getControl(name='form.button.save').click()
self.changeTitle(baseurl, newtitle)
self.assertTrue(newtitle in self.browser.contents)

def test_condition_should_allow_commit(self):
Expand All @@ -72,9 +79,7 @@ def test_condition_should_allow_commit(self):
newtitle = "EDITED TITLE"
self.browser.open(baseurl)
self.assertTrue(newtitle not in self.browser.contents)
self.browser.open(baseurl + '/edit')
self.browser.getControl(name='title').value = newtitle
self.browser.getControl(name='form.button.save').click()
self.changeTitle(baseurl, newtitle)
self.assertTrue(newtitle in self.browser.contents)

def test_show_status_message(self):
Expand Down

0 comments on commit 064a60b

Please sign in to comment.