Skip to content

Commit

Permalink
add cmfdocument from CMFDefault to allow testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed Jun 18, 2015
1 parent 2b3b389 commit da22c4b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
14 changes: 13 additions & 1 deletion Products/contentmigration/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# And as if by magic, this folder is a python package
# initialize cmf test content
from Products.CMFCore import permissions

def initialize(context):
import Products.contentmigration.testcontent
from Products.CMFCore import utils
utils.ContentInit(
'CMF Default Content',
content_types=(),
permission=permissions.AddPortalContent,
extra_constructors=(testcontent.addDocument,),
visibility=None,
).initialize(context)
3 changes: 3 additions & 0 deletions Products/contentmigration/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five"
i18n_domain="Products.contentmigration">

<five:registerPackage package="." initialize=".initialize" />

</configure>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
They may also contain HTML, or "plain" text.</property>
<property name="content_icon">document_icon.gif</property>
<property name="content_meta_type">Document</property>
<property name="product">CMFDefault</property>
<property name="product">contentmigration</property>
<property name="factory">addDocument</property>
<property name="immediate_view">document_view</property>
<property name="global_allow">False</property>
Expand Down
25 changes: 25 additions & 0 deletions Products/contentmigration/testcontent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from App.class_init import InitializeClass
from Products.Archetypes import atapi
from Products.CMFCore.PortalContent import PortalContent
from zope.component.factory import Factory

def addDocument(self, id, title='', description='', text_format='', text=''):
"""Add a Document.
"""
o = Document(id, title, description, text_format, text)
self._setObject(id, o, suppress_events=True)


class Document(PortalContent):
""" A Document """

def __init__(self, id, title='', description='', text_format='', text=''):
self.id = id
self.title = title
self.description = description

def Title(self):
return self.title

InitializeClass(Document)
DocumentFactory = Factory(Document)
16 changes: 16 additions & 0 deletions Products/contentmigration/tests/layer.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
from plone.app.testing import bbb
from plone.app import testing
from plone.testing import z2
from Products.GenericSetup import EXTENSION, profile_registry


def setupSampleTypeProfile():
profile_registry.registerProfile('CMF_sampletypes',
'CMF Sample Content Types',
'Extension profile including CMF sample content types',
'profiles/testing',
'Products.contentmigration',
EXTENSION)


class PloneTestCaseFixture(bbb.PloneTestCaseFixture):

defaultBases = (bbb.PTC_FIXTURE, )

def setUpZope(self, app, configurationContext):
setupSampleTypeProfile()
from Products import contentmigration
self.loadZCML('testing.zcml', package=contentmigration)
self.loadZCML('testing-schemaextender.zcml', package=contentmigration)
z2.installProduct(app, 'Products.contentmigration')

def setUpPloneSite(self, portal):
testing.applyProfile(portal, 'Products.contentmigration:CMF_sampletypes')

PCM_FIXTURE = PloneTestCaseFixture()
TestLayer = testing.FunctionalTesting(
Expand Down

0 comments on commit da22c4b

Please sign in to comment.