diff --git a/Products/CMFPlone/tests/testCSRFProtection.py b/Products/CMFPlone/tests/testCSRFProtection.py index 92b4180d55..de3116eb1c 100644 --- a/Products/CMFPlone/tests/testCSRFProtection.py +++ b/Products/CMFPlone/tests/testCSRFProtection.py @@ -5,7 +5,7 @@ from plone.app.testing.bbb import PloneTestCase from plone.keyring.interfaces import IKeyManager from plone.protect.authenticator import AuthenticatorView -from six import StringIO +from six import BytesIO from zope.component import queryUtility @@ -20,7 +20,7 @@ def test_KeyManager(self): def checkAuthenticator(self, path, query='', status=200): credentials = '%s:%s' % (TEST_USER_NAME, TEST_USER_PASSWORD) path = '/' + self.portal.absolute_url(relative=True) + path - data = StringIO(query) + data = BytesIO(query.encode('utf8')) # without authenticator... response = self.publish(path=path, basic=credentials, env={}, request_method='POST', stdin=data) @@ -28,7 +28,8 @@ def checkAuthenticator(self, path, query='', status=200): # with authenticator... tag = AuthenticatorView('context', 'request').authenticator() token = tag.split('"')[5] - data = StringIO(query + '&_authenticator=%s' % token) + query = query + '&_authenticator=%s' % token + data = BytesIO(query.encode('utf8')) response = self.publish(path=path, basic=credentials, env={}, request_method='POST', stdin=data) self.assertEqual(response.getStatus(), status) diff --git a/Products/CMFPlone/tests/testCatalogTool.py b/Products/CMFPlone/tests/testCatalogTool.py index c64e08ff49..44ea039cdd 100644 --- a/Products/CMFPlone/tests/testCatalogTool.py +++ b/Products/CMFPlone/tests/testCatalogTool.py @@ -6,6 +6,7 @@ from plone.app.testing import setRoles from plone.app.testing import TEST_USER_ID from plone.app.testing import TEST_USER_NAME +from plone.app.textfield import RichTextValue from plone.indexer.wrapper import IndexableObjectWrapper from plone.uuid.interfaces import IAttributeUUID from plone.uuid.interfaces import IUUID @@ -334,7 +335,8 @@ def testClearFindAndRebuildAddsMissingContent(self): def testClearFindAndRebuildKeepsModificationDate(self): # Index the doc for consistency self.catalog.indexObject(self.folder.doc) - self.folder.doc.setModificationDate(DateTime(0)) + self.folder.doc.modification_date = DateTime(0) + # FIXME: Index the doc for consistency self.catalog.clearFindAndRebuild() self.assertEqual(self.folder.doc.modified(), DateTime(0)) self.assertEqual(len(self.catalog(modified=DateTime(0))), 1) @@ -1285,7 +1287,8 @@ def test_provided(self): def test_getObjSize(self): from Products.CMFPlone.CatalogTool import getObjSize get_size = getObjSize.callable - self.doc.setText(u'a' * 1000) + # FIXME: getObjSize die not count text in DX + self.doc.text = RichTextValue('a' * 1000) self.doc.reindexObject() self.assertEqual(get_size(self.doc), '1 KB') @@ -1303,11 +1306,11 @@ class TestMetadata(PloneTestCase): def testLocationAddedToMetdata(self): self.folder.invokeFactory( - 'Document', 'doc', title='document', location="foobar") + 'Document', 'doc', title='document', location='foobar') doc = self.folder.doc catalog = self.portal.portal_catalog brain = catalog(UID=doc.UID())[0] - self.assertEqual(brain.location, doc.getLocation()) + self.assertEqual(brain.location, doc.location) class TestObjectProvidedIndexExtender(unittest.TestCase): diff --git a/Products/CMFPlone/tests/testContentTypeScripts.py b/Products/CMFPlone/tests/testContentTypeScripts.py index 4131c6bd46..4cb896a372 100644 --- a/Products/CMFPlone/tests/testContentTypeScripts.py +++ b/Products/CMFPlone/tests/testContentTypeScripts.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +from plone.app.textfield import RichTextValue +from plone.namedfile.file import NamedFile from Products.CMFPlone.tests import PloneTestCase from Products.CMFPlone.tests import dummy @@ -17,8 +19,9 @@ def getPermissionsOfRole(self, role): return [p['name'] for p in perms if p['selected']] def testDocumentCreate(self): - self.folder.invokeFactory('Document', id='doc', text='data') - self.assertEqual(self.folder.doc.EditableBody(), 'data') + self.folder.invokeFactory( + 'Document', id='doc', text=RichTextValue(u'data')) + self.assertEqual(self.folder.doc.text.raw, 'data') self.assertEqual(self.folder.doc.Format(), 'text/plain') def testEventCreate(self): @@ -27,18 +30,20 @@ def testEventCreate(self): start_date='2003-09-18', end_date='2003-09-19') self.assertEqual(self.folder.event.Title(), 'Foo') - self.assertTrue(self.folder.event.start().ISO8601() + self.assertTrue(self.folder.event.start.ISO8601() .startswith('2003-09-18T00:00:00')) - self.assertTrue(self.folder.event.end().ISO8601() + self.assertTrue(self.folder.event.end.ISO8601() .startswith('2003-09-19T00:00:00')) def testFileCreate(self): - self.folder.invokeFactory('File', id='file', file=dummy.File()) - self.assertEqual(str(self.folder.file), dummy.TEXT) + self.folder.invokeFactory( + 'File', id='file', file=NamedFile(dummy.File())) + self.assertEqual(self.folder.file.file.data, dummy.TEXT) def testImageCreate(self): - self.folder.invokeFactory('Image', id='image', file=dummy.Image()) - self.assertEqual(str(self.folder.image.data), dummy.GIF) + self.folder.invokeFactory( + 'Image', id='image', image=NamedImage(dummy.Image())) + self.assertEqual(self.folder.image.image.data, dummy.GIF) def testFolderCreate(self): self.folder.invokeFactory('Folder', id='folder', title='Foo', @@ -50,12 +55,12 @@ def testLinkCreate(self): self.folder.invokeFactory('Link', id='link', remote_url='http://foo.com', title='Foo') self.assertEqual(self.folder.link.Title(), 'Foo') - self.assertEqual(self.folder.link.getRemoteUrl(), 'http://foo.com') + self.assertEqual(self.folder.link.remote_url, 'http://foo.com') def testNewsItemCreate(self): self.folder.invokeFactory('News Item', id='newsitem', - text='data', title='Foo') - self.assertEqual(self.folder.newsitem.EditableBody(), 'data') + text=RichTextValue(u'data'), title='Foo') + self.assertEqual(self.folder.newsitem.text.raw, 'data') self.assertEqual(self.folder.newsitem.Title(), 'Foo') # Bug tests @@ -77,33 +82,33 @@ class TestFileURL(PloneTestCase.PloneTestCase): def testFileURLWithHost(self): self.folder.invokeFactory('Link', id='link', remote_url='file://foo.com/baz.txt') - self.assertEqual(self.folder.link.getRemoteUrl(), + self.assertEqual(self.folder.link.remote_url, 'file://foo.com/baz.txt') def testFileURLNoHost(self): self.folder.invokeFactory('Link', id='link', remote_url='file:///foo.txt') - self.assertEqual(self.folder.link.getRemoteUrl(), 'file:///foo.txt') + self.assertEqual(self.folder.link.remote_url, 'file:///foo.txt') def testFileURLFourSlash(self): self.folder.invokeFactory('Link', id='link', remote_url='file:////foo.com/baz.txt') # See urlparse.urlparse() - self.assertEqual(self.folder.link.getRemoteUrl(), + self.assertEqual(self.folder.link.remote_url, 'file://foo.com/baz.txt') def testFileURLFiveSlash(self): self.folder.invokeFactory('Link', id='link', remote_url='file://///foo.com/baz.txt') # See urlparse.urlparse() - self.assertEqual(self.folder.link.getRemoteUrl(), + self.assertEqual(self.folder.link.remote_url, 'file:///foo.com/baz.txt') def testFileURLSixSlash(self): self.folder.invokeFactory('Link', id='link', remote_url='file://////foo.com/baz.txt') # See urlparse.urlparse() - self.assertEqual(self.folder.link.getRemoteUrl(), + self.assertEqual(self.folder.link.remote_url, 'file:////foo.com/baz.txt') @@ -111,7 +116,7 @@ class TestImageProps(PloneTestCase.PloneTestCase): def testImageComputedProps(self): from OFS.Image import Image - tag = Image.tag.im_func + tag = Image.tag kw = {'_title': 'some title', '_alt': 'alt tag', 'height': 100, diff --git a/Products/CMFPlone/tests/testSearch.py b/Products/CMFPlone/tests/testSearch.py index 96bc561e50..25a584d4eb 100644 --- a/Products/CMFPlone/tests/testSearch.py +++ b/Products/CMFPlone/tests/testSearch.py @@ -15,6 +15,7 @@ from Products.CMFPlone.interfaces import ISearchSchema from plone.app.contentlisting.interfaces import IContentListing +from plone.app.textfield import RichTextValue from zope.configuration import xmlconfig from zope.interface import alsoProvides @@ -58,19 +59,19 @@ def setUpZope(self, app, configurationContext): import plone.app.contentlisting xmlconfig.file('configure.zcml', plone.app.contentlisting, context=configurationContext) - z2.installProduct(app, 'Products.ATContentTypes') def setUpPloneSite(self, portal): # Install into Plone site using portal_setup if 'Document' not in portal.portal_types: - applyProfile(portal, 'Products.ATContentTypes:default') + applyProfile(portal, 'plone.app.contenttypes:default') setRoles(portal, TEST_USER_ID, ['Manager']) login(portal, TEST_USER_NAME) for i in range(0, 12): portal.invokeFactory( 'Document', 'my-page' + str(i), - text='spam spam ham eggs' + text=RichTextValue( + u'spam spam ham eggs', 'text/html', 'text/x-html-safe'), ) # Sleep before creating the next one, otherwise ordering by date is # not deterministic.