from plone.app.testing import ploneSite 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.testing import TEST_USER_PASSWORD from plone.namedfile.file import NamedImage from plone.testing import z2 from Products.Archetypes.interfaces import IBaseObject from Products.CMFCore.utils import getToolByName from six import StringIO from zope.configuration import xmlconfig B64_DATA = 'R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=' GIF = StringIO(decodestring(B64_DATA)) GIF.filename = 'sample.gif' GIF.contentType = 'image/gif' GIF._width = 1 GIF._height = 1 def create(container, type_name, **kwargs): """A easy helper method to create some content since we do not have plone.api in core. """ new_id = container.invokeFactory(type_name, **kwargs) content = container[new_id] # Archetypes specific code was taken from ``plone.api`` # Switch when api has been merged into core. if IBaseObject.providedBy(content):