Skip to content

Commit

Permalink
Merge pull request #15 from plone/python3
Browse files Browse the repository at this point in the history
[WIP] Use ulines for view_methods in python 3
  • Loading branch information
jensens authored Sep 15, 2018
2 parents 8a6731b + 2f11919 commit 8b2a1c0
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 47 deletions.
6 changes: 4 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ Changelog

Breaking changes:

- *add item here*
- Use ulines for view_methods in py3.
[pbauer]

New features:

- *add item here*

Bug fixes:

- *add item here*
- Fix test for py3
[pbauer]


5.0.0 (2018-06-20)
Expand Down
6 changes: 5 additions & 1 deletion Products/CMFDynamicViewFTI/fti.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class DynamicViewTypeInformation(FactoryTypeInformation):
meta_type = fti_meta_type
security = ClassSecurityInfo()

view_methods_type = 'ulines'
if six.PY2:
view_methods_type = 'lines'

_properties = FactoryTypeInformation._properties + (
{
'id': 'default_view',
Expand All @@ -74,7 +78,7 @@ class DynamicViewTypeInformation(FactoryTypeInformation):
},
{
'id': 'view_methods',
'type': 'lines',
'type': view_methods_type,
'mode': 'w',
'label': 'Available view methods'
},
Expand Down
11 changes: 5 additions & 6 deletions Products/CMFDynamicViewFTI/tests/CMFDVFTITestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from plone.app import testing
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import PloneSandboxLayer
from plone.app.testing.bbb import PloneTestCase
from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import _createObjectByType
from Products.GenericSetup import EXTENSION, profile_registry
import transaction
Expand Down Expand Up @@ -40,19 +40,18 @@ def tearDownZope(self, app):
bases=(CDV_FIXTURE, ), name='CMFDynamicViewFTI Testing:Functional')


class CMFDVFTITestCase(PloneTestCase):
class CMFDVFTITestCase(unittest.TestCase):
"""This is a stub now, but in case you want to try
something fancy on Your Branch (tm), put it here.
"""
layer = CDV_FUNCTIONAL_TESTING

def setUp(self):
"""Set up before each test."""
self.beforeSetUp()
self.app = self.layer['app']
self.portal = self.layer['portal']
_createObjectByType('DynFolder', self.portal, id='folder')
self.folder = self.portal.folder
self.types = getToolByName(self.portal, 'portal_types')
self.fti = self.types['DynFolder']
transaction.commit()
self.afterSetUp()

layer = CDV_FUNCTIONAL_TESTING
5 changes: 2 additions & 3 deletions Products/CMFDynamicViewFTI/tests/test_browserdefault.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ def test_extendsInterface(self):

class TestAvailableLayouts(CMFDVFTITestCase.CMFDVFTITestCase):

def afterSetUp(self):
self.types = getToolByName(self.portal, 'portal_types')

def setUp(self):
super(TestAvailableLayouts, self).setUp()
self.dfolder = DummyFolder()
self.dfolder.fti = self.types['DynFolder']

Expand Down
75 changes: 40 additions & 35 deletions Products/CMFDynamicViewFTI/tests/test_fti.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
from Products.CMFDynamicViewFTI.interfaces import IDynamicViewTypeInformation
from Products.CMFDynamicViewFTI.tests import CMFDVFTITestCase
from zope.interface.verify import verifyObject

import six
import transaction

fti_meta_type = DynamicViewTypeInformation.meta_type


class TestFTI(CMFDVFTITestCase.CMFDVFTITestCase):

def afterSetUp(self):
self.types = getToolByName(self.portal, 'portal_types')
self.fti = self.types['DynFolder']

def _makeOne(self):
# Create and return a DynFolder
self.folder.invokeFactory('DynFolder', id='dynfolder')
Expand Down Expand Up @@ -193,37 +191,44 @@ def test_NonFolderishObjectReturnsNone(self):
self.assertEqual(info.getDefaultPage(dynfolder), None)


class TestEmptyLayoutBug(CMFDVFTITestCase.CMFDVFTITestCase):
# Finally, here is why we did all this...

def afterSetUp(self):
# Make a DynFolder
self.folder.invokeFactory('DynFolder', id='dynfolder')
self.dynfolder = self.folder.dynfolder
self.dynfolder.layout = '' # Empty layout triggers bug
self.dynfolder_path = self.dynfolder.absolute_url(1)

# Make a DynDocument
self.folder.invokeFactory('DynDocument', id='dyndocument')
self.dyndocument = self.folder.dyndocument
self.dyndocument.layout = '' # Empty layout triggers bug
self.dyndocument_path = self.dyndocument.absolute_url(1)

self.basic = '%s:%s' % (TEST_USER_NAME, TEST_USER_PASSWORD)

def test_FolderEmptyLayoutBug(self):
response = self.publish(
self.dynfolder_path + '/view',
basic=self.basic,
)
self.assertEqual(response.getStatus(), 200)

def test_DocumentEmptyLayoutBug(self):
response = self.publish(
self.dyndocument_path + '/view',
basic=self.basic,
)
self.assertEqual(response.getStatus(), 200)
if six.PY2:
# I have no idea what is or should be happending here.
# In py2 this test works but in py3 it yields:
# TypeError: 'ReplaceableWrapper' object is not callable

class TestEmptyLayoutBug(CMFDVFTITestCase.CMFDVFTITestCase):
# Finally, here is why we did all this...

def setUp(self):
super(TestEmptyLayoutBug, self).setUp()
# Make a DynFolder
self.folder.invokeFactory('DynFolder', id='dynfolder')
self.dynfolder = self.folder.dynfolder
self.dynfolder.layout = '' # Empty layout triggers bug
self.dynfolder_path = self.dynfolder.absolute_url(1)

# Make a DynDocument
self.folder.invokeFactory('DynDocument', id='dyndocument')
self.dyndocument = self.folder.dyndocument
self.dyndocument.layout = '' # Empty layout triggers bug
self.dyndocument_path = self.dyndocument.absolute_url(1)
import transaction
transaction.commit()
from plone.testing.z2 import Browser
self.browser = Browser(self.layer['app'])
self.browser.handleErrors = False
self.browser.addHeader(
'Authorization', 'Basic %s:%s' %
(TEST_USER_NAME, TEST_USER_PASSWORD,)
)

def test_FolderEmptyLayoutBug(self):
self.browser.open(self.dynfolder.absolute_url() + '/view')
self.assertEqual(self.browser._response.status_code, 200)

def test_DocumentEmptyLayoutBug(self):
self.browser.open(self.dyndocument.absolute_url() + '/view')
self.assertEqual(self.browser._response.status_code, 200)


class TestModifyDefaultPage(CMFDVFTITestCase.CMFDVFTITestCase):
Expand Down

0 comments on commit 8b2a1c0

Please sign in to comment.