Permalink
Browse files

Pages: add tests for adding dexterity objects.

  • Loading branch information...
1 parent d2a00db commit 486ab5981cbe1227a736c57d8b2a23281829ccef @jone jone committed Mar 29, 2013
@@ -200,6 +200,15 @@ def open_add_form(self, type_name):
browser().find_by_xpath(
"//span[text() = 'Add new\xe2\x80\xa6']").click()
+ factories = [
+ self.normalize_whitespace(item.text) for item
+ in browser().find_by_css(
+ '#plone-contentmenu-factories li a span')]
+
+ assert self.normalize_whitespace(type_name) in factories, \
+ 'The type "%s" is not addable. Addable types: %s' % (
+ type_name, str(factories))
+
self.find_one_by_xpath(
'//a/span[normalize-space(text()) = "%s"]/..' % type_name).click()
@@ -1,12 +1,29 @@
from ftw.testing import FunctionalSplinterTesting
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import PloneSandboxLayer
+from plone.app.testing import applyProfile
+from zope.configuration import xmlconfig
class PageObjectLayer(PloneSandboxLayer):
defaultBases = (PLONE_FIXTURE, )
+ def setUpZope(self, app, configurationContext):
+ import plone.app.dexterity
+ xmlconfig.file('configure.zcml',
+ plone.app.dexterity,
+ context=configurationContext)
+
+ import ftw.testing.tests
+ xmlconfig.file('profiles/dxtype.zcml',
+ ftw.testing.tests,
+ context=configurationContext)
+
+ def setUpPloneSite(self, portal):
+ applyProfile(
+ portal, 'ftw.testing.tests:dxtype')
+
PAGE_OBJECT_FIXTURE = PageObjectLayer()
PAGE_OBJECT_FUNCTIONAL = FunctionalSplinterTesting(
@@ -0,0 +1,5 @@
+from zope.interface import Interface
+
+
+class IDXTypeSchema(Interface):
+ pass
@@ -0,0 +1,16 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
+ i18n_domain="ftw.testing.tests">
+
+ <include package="Products.GenericSetup" file="meta.zcml" />
+
+ <genericsetup:registerProfile
+ name="dxtype"
+ title="ftw.tresting.tests:dxtype"
+ directory="dxtype"
+ description=""
+ provides="Products.GenericSetup.interfaces.EXTENSION"
+ />
+
+</configure>
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<metadata>
+ <version>1000</version>
+ <dependencies>
+ <dependency>profile-plone.app.dexterity:default</dependency>
+ </dependencies>
+</metadata>
@@ -0,0 +1,3 @@
+<object name="portal_types">
+ <object name="DXType" meta_type="Dexterity FTI" />
+</object>
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<object name="DXType"
+ meta_type="Dexterity FTI"
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+ i18n:domain="ftw.testing.tests" >
+
+ <!-- Basic metadata -->
+ <property name="title">DXType</property>
+ <property name="global_allow">True</property>
+ <property name="add_permission">cmf.AddPortalContent</property>
+
+ <!-- schema interface -->
+ <property name="schema">ftw.testing.tests.interfaces.IDXTypeSchema</property>
+
+ <!-- class used for content items -->
+ <property name="klass">plone.dexterity.content.Item</property>
+
+ <!-- enabled behaviors -->
+ <property name="behaviors">
+ <element value="plone.app.dexterity.behaviors.metadata.IBasic" />
+ <element value="plone.app.content.interfaces.INameFromTitle" />
+ </property>
+
+ <!-- View information -->
+ <property name="default_view">view</property>
+ <property name="default_view_fallback">False</property>
+ <property name="view_methods">
+ <element value="view"/>
+ </property>
+
+ <!-- Method aliases -->
+ <alias from="(Default)" to="(dynamic view)"/>
+ <alias from="edit" to="@@edit"/>
+ <alias from="sharing" to="@@sharing"/>
+ <alias from="view" to="(selected layout)"/>
+
+ <!-- Actions -->
+ <action
+ action_id="view"
+ title="View"
+ category="object"
+ condition_expr=""
+ url_expr="string:${object_url}"
+ visible="True">
+ <permission value="View"/>
+ </action>
+
+ <action
+ action_id="edit"
+ title="Edit"
+ category="object"
+ condition_expr=""
+ url_expr="string:${object_url}/edit"
+ visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+
+</object>
@@ -182,3 +182,24 @@ def test_create_object__JAVASCRIPT(self):
bold = browser().find_by_xpath('//strong[text()="%s"]' % text).first
self.assertEquals(text, bold.text,
'Insert HTML strong tag could not be found.')
+
+ def test_DEXTERITY_create_object_ZOPE_TESTBROWSER(self):
+ Plone().login(SITE_OWNER_NAME, SITE_OWNER_PASSWORD)
+ Plone().visit_portal()
+
+ Plone().create_object('DXType', {'Title': 'Bar'})
+
+ self.assertEquals('%s/bar/view' % Plone().portal_url, browser().url)
+ self.assertEquals('Bar', Plone().get_first_heading(),
+ 'Title of newly created page is wrong.')
+
+ @javascript
+ def test_DEXTERITY_create_object_JAVASCRIPT(self):
+ Plone().login(SITE_OWNER_NAME, SITE_OWNER_PASSWORD)
+ Plone().visit_portal()
+
+ Plone().create_object('DXType', {'Title': 'Bar'})
+
+ self.assertEquals('%s/bar/view' % Plone().portal_url, browser().url)
+ self.assertEquals('Bar', Plone().get_first_heading(),
+ 'Title of newly created page is wrong.')
View
@@ -21,6 +21,7 @@
'Products.PloneHotfix20121106',
'Plone',
'plone.app.testing',
+ 'plone.app.dexterity',
] + extras_require['robot'] + extras_require['splinter']
extras_require['tests'] = tests_require

0 comments on commit 486ab59

Please sign in to comment.