Permalink
Browse files

add staging behavior tests contributed by Anthony -- thanks

svn path=/plone.app.stagingbehavior/trunk/; revision=49404
  • Loading branch information...
davisagli committed May 11, 2011
1 parent b2bed25 commit b821b6406789ec1f7681f6b2918b95b229a64287
View
@@ -26,7 +26,7 @@ In your *profiles/default/types/YOURTYPE.xml* add the behavior::
</object>
-The IStagingSupport behavior just adds the refered staging support to your
+The IStagingSupport behavior just adds the referred staging support to your
content-type, but it does not enable it.
You have to set the "versioning" option in the Plone types control panel
View
@@ -4,6 +4,8 @@ Changelog
0.1a3 (Unreleased)
------------------
+* Add functional tests.
+ [anthonygerrard, davisagli]
0.1a2 (2011-01-25)
------------------
@@ -1,5 +1,6 @@
<configure
xmlns="http://namespaces.zope.org/zope"
+ xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
xmlns:grok="http://namespaces.zope.org/grok"
xmlns:plone="http://namespaces.plone.org/plone">
@@ -21,5 +22,15 @@
for="plone.app.iterate.interfaces.IAfterCheckinEvent"
handler="plone.app.iterate.subscribers.locking.handleCheckin"
/>
+
+
+ <genericsetup:registerProfile
+ name="testfixture"
+ title="plone.app.stagingbehavior: Test fixture"
+ directory="profiles/testfixture"
+ description="Extension profile to configure a test fixture"
+ for="Products.CMFPlone.interfaces.ITestCasePloneSiteRoot"
+ provides="Products.GenericSetup.interfaces.EXTENSION"
+ />
</configure>
@@ -0,0 +1,7 @@
+<metadata>
+ <version>1</version>
+ <dependencies>
+ <dependency>profile-plone.app.dexterity:default</dependency>
+ <dependency>profile-plone.app.iterate:plone.app.iterate</dependency>
+ </dependencies>
+</metadata>
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<repositorytool>
+ <policymap purge="true">
+ <type name="stageable_type">
+ <policy name="at_edit_autoversion"/>
+ <policy name="version_on_revert"/>
+ </type>
+ </policymap>
+</repositorytool>
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<object name="portal_types" meta_type="Plone Types Tool">
+ <object name="stageable_type" meta_type="Dexterity FTI"/>
+ <object name="test_folder" meta_type="Dexterity FTI"/>
+</object>
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<object name="article" meta_type="Dexterity FTI"
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title">Stageable Type</property>
+ <property name="description"></property>
+ <property name="icon_expr">string:${portal_url}/document_icon.png</property>
+ <property name="factory">stageable_type</property>
+ <property name="link_target"></property>
+ <property name="immediate_view">view</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <property name="default_view">view</property>
+ <property name="view_methods">
+ <element value="view"/>
+ </property>
+ <property name="default_view_fallback">False</property>
+ <property name="add_permission">cmf.AddPortalContent</property>
+ <property name="klass">plone.dexterity.content.Item</property>
+ <property name="behaviors">
+ <element value="plone.app.dexterity.behaviors.metadata.IDublinCore"/>
+ <element
+ value="plone.app.referenceablebehavior.referenceable.IReferenceable"/>
+ <element value="plone.app.stagingbehavior.interfaces.IStagingSupport" />
+ <element value="plone.app.versioningbehavior.behaviors.IVersionable" />
+ </property>
+ <property name="schema"></property>
+ <property name="model_source"></property>
+ <property name="model_file">plone.app.stagingbehavior.tests:stageable_type.xml</property>
+ <alias from="(Default)" to="(dynamic view)"/>
+ <alias from="edit" to="@@edit"/>
+ <alias from="sharing" to="@@sharing"/>
+ <alias from="view" to="(selected layout)"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ icon_expr="" link_target="" url_expr="string:${object_url}"
+ visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ icon_expr="" link_target="" url_expr="string:${object_url}/edit"
+ visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+</object>
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<object name="test_folder" meta_type="Dexterity FTI"
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title">Test Folder</property>
+ <property name="description"></property>
+ <property name="icon_expr"></property>
+ <property name="factory">test_folder</property>
+ <property name="link_target"></property>
+ <property name="immediate_view">view</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">False</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <property name="default_view">view</property>
+ <property name="view_methods">
+ <element value="view"/>
+ </property>
+ <property name="default_view_fallback">False</property>
+ <property name="add_permission">cmf.AddPortalContent</property>
+ <property name="klass">plone.dexterity.content.Container</property>
+ <property name="behaviors">
+ <element value="plone.app.dexterity.behaviors.metadata.IDublinCore"/>
+ <element
+ value="plone.app.referenceablebehavior.referenceable.IReferenceable"/>
+ <element value="plone.app.versioningbehavior.behaviors.IVersionable" />
+ <element value="plone.app.layout.navigation.interfaces.INavigationRoot"/>
+ </property>
+ <property name="schema"></property>
+ <property name="model_source"></property>
+ <property name="model_file">plone.app.stagingbehavior.tests:folder.xml</property>
+ <alias from="(Default)" to="(dynamic view)"/>
+ <alias from="edit" to="@@edit"/>
+ <alias from="sharing" to="@@sharing"/>
+ <alias from="view" to="(selected layout)"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ icon_expr="" link_target="" url_expr="string:${object_url}/view"
+ visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ icon_expr="" link_target="" url_expr="string:${object_url}/edit"
+ visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+</object>
@@ -0,0 +1,80 @@
+Staging behavior
+======================
+
+A Dexterity content type is created by our textfixture profile.
+
+If we access the site as an admin TTW::
+
+ >>> from plone.testing.z2 import Browser
+ >>> browser = Browser(layer['app'])
+ >>> browser.handleErrors = False
+ >>> portal = layer['portal']
+ >>> portal_url = 'http://nohost/plone'
+ >>> from plone.app.testing.interfaces import SITE_OWNER_NAME, SITE_OWNER_PASSWORD
+ >>> browser.addHeader('Authorization', 'Basic %s:%s' % (SITE_OWNER_NAME, SITE_OWNER_PASSWORD))
+
+We can see this type in the addable types at the root of the site::
+
+ >>> browser.open(portal_url)
+ >>> browser.open(portal_url + "/folder_factories")
+ >>> browser.contents
+ '...stageable_type...'
+ >>> browser.getControl("Stageable Type").click()
+ >>> browser.getControl("Add").click()
+ >>> browser.getControl(name="form.widgets.IDublinCore.title").value = "My Object"
+ >>> browser.getControl(name="form.buttons.save").click()
+ >>> browser.url
+ 'http://nohost/plone/stageable_type/view'
+
+Checkout
+
+ >>> browser.getLink(id='iterate_checkout').click()
+ >>> browser.contents
+ '...This is a working copy of ...My Object..., made by...admin... on ...'
+
+Cancel checkout
+
+ >>> browser.getLink(id='iterate_checkout_cancel').click()
+ >>> browser.contents
+ '...Cancel check-out of...My Object...'
+ >>> browser.getControl(name='form.button.Cancel').click()
+ >>> browser.url
+ 'http://nohost/plone/stageable_type'
+
+Test inside a folder
+--------------------
+
+ >>> browser.open(portal_url + "/folder_factories")
+ >>> browser.contents
+ '...test_folder...'
+ >>> browser.getControl("Test Folder").click()
+ >>> browser.getControl("Add").click()
+ >>> browser.getControl(name="form.widgets.IDublinCore.title").value = "My Folder"
+ >>> browser.getControl(name="form.buttons.save").click()
+ >>> browser.url
+ 'http://nohost/plone/test_folder/view'
+
+ >>> browser.open("http://nohost/plone/test_folder/folder_factories")
+ >>> browser.contents
+ '...stageable_type...'
+ >>> browser.getControl("Stageable Type").click()
+ >>> browser.getControl("Add").click()
+ >>> browser.getControl(name="form.widgets.IDublinCore.title").value = "My Sub-object"
+ >>> browser.getControl(name="form.buttons.save").click()
+ >>> browser.url
+ 'http://nohost/plone/test_folder/stageable_type/view'
+
+Checkout
+
+ >>> browser.getLink(id='iterate_checkout').click()
+ >>> browser.contents
+ '...This is a working copy of ...My Sub-object..., made by...admin... on ...'
+
+Cancel checkout
+
+ >>> browser.getLink(id='iterate_checkout_cancel').click()
+ >>> browser.contents
+ '...Cancel check-out of...My Sub-object...'
+ >>> browser.getControl(name='form.button.Cancel').click()
+ >>> browser.url
+ 'http://nohost/plone/test_folder/stageable_type'
@@ -0,0 +1,28 @@
+from plone.app.testing import PloneSandboxLayer
+from plone.app.testing import PLONE_FIXTURE
+from plone.app.testing import IntegrationTesting, FunctionalTesting
+from plone.app.testing import applyProfile
+from zope.configuration import xmlconfig
+
+class Fixture(PloneSandboxLayer):
+ default_bases = (PLONE_FIXTURE,)
+
+ def setUpZope(self, app, configurationContext):
+ import plone.app.stagingbehavior
+ xmlconfig.include(configurationContext, 'configure.zcml', plone.app.stagingbehavior)
+ configurationContext.execute_actions()
+
+ def setUpPloneSite(self, portal):
+ applyProfile(portal, 'plone.app.stagingbehavior:testfixture')
+
+
+FIXTURE = Fixture()
+
+INTEGRATION_TESTING = IntegrationTesting(
+ bases=(FIXTURE,),
+ name="plone.app.stagingbehavior:Integration",
+ )
+FUNCTIONAL_TESTING = FunctionalTesting(
+ bases=(FIXTURE,),
+ name="plone.app.stagingbehavior:Functional",
+ )
@@ -0,0 +1,4 @@
+<model xmlns="http://namespaces.plone.org/supermodel/schema">
+<schema>
+</schema>
+</model>
@@ -0,0 +1,4 @@
+<model xmlns="http://namespaces.plone.org/supermodel/schema"
+ xmlns:marshal="http://namespaces.plone.org/supermodel/marshal">
+<schema></schema>
+</model>
@@ -0,0 +1,17 @@
+from plone.testing import layered
+
+from plone.app.stagingbehavior.tests.base import FUNCTIONAL_TESTING
+
+import doctest
+import unittest
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTests([
+ layered(doctest.DocFileSuite('../stagingbehavior.txt', optionflags = doctest.ELLIPSIS),
+ layer = FUNCTIONAL_TESTING),
+ ])
+ return suite
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
View
@@ -24,12 +24,18 @@
zip_safe=False,
install_requires=[
'setuptools',
+ 'Products.CMFPlone',
'plone.app.dexterity',
'plone.app.iterate',
+ 'plone.app.versioningbehavior',
+ 'plone.app.referenceablebehavior',
'plone.locking',
'z3c.relationfield',
# -*- Extra requirements: -*-
],
+ extras_require = {
+ 'test': ['plone.app.testing'],
+ },
entry_points="""
# -*- Entry points: -*-
[z3c.autoinclude.plugin]

0 comments on commit b821b64

Please sign in to comment.