[z3-checkins] r10811 - in z3/Five/trunk/tests: . products/FiveTest
regebro at codespeak.net
regebro at codespeak.net
Mon Apr 18 14:55:08 MEST 2005
Author: regebro
Date: Mon Apr 18 14:55:08 2005
New Revision: 10811
Modified:
z3/Five/trunk/tests/products/FiveTest/browser.py
z3/Five/trunk/tests/products/FiveTest/configure.zcml
z3/Five/trunk/tests/products/FiveTest/fancycontent.py
z3/Five/trunk/tests/products/FiveTest/interfaces.py
z3/Five/trunk/tests/test_editform.py
Log:
Test for object widget
Modified: z3/Five/trunk/tests/products/FiveTest/browser.py
==============================================================================
--- z3/Five/trunk/tests/products/FiveTest/browser.py (original)
+++ z3/Five/trunk/tests/products/FiveTest/browser.py Mon Apr 18 14:55:08 2005
@@ -1,5 +1,8 @@
from Products.Five import BrowserView
from Products.Five import StandardMacros as BaseMacros
+from simplecontent import FieldSimpleContent
+from zope.app.form import CustomWidgetFactory
+from zope.app.form.browser import ObjectWidget
class SimpleContentView(BrowserView):
"""More docstring. Please Zope"""
@@ -55,3 +58,8 @@
macro_pages = ('bird_macros', 'dog_macros')
aliases = {'flying':'birdmacro',
'walking':'dogmacro'}
+
+class ComplexSchemaView:
+ """Needs a docstring"""
+
+ fish_widget = CustomWidgetFactory(ObjectWidget, FieldSimpleContent)
\ No newline at end of file
Modified: z3/Five/trunk/tests/products/FiveTest/configure.zcml
==============================================================================
--- z3/Five/trunk/tests/products/FiveTest/configure.zcml (original)
+++ z3/Five/trunk/tests/products/FiveTest/configure.zcml Mon Apr 18 14:55:08 2005
@@ -310,6 +310,24 @@
permission="zope2.Public"
/>
+ <five:traversable class=".fancycontent.ComplexSchemaContent" />
+
+ <browser:editform
+ schema=".interfaces.IComplexSchemaContent"
+ for=".interfaces.IComplexSchemaContent"
+ name="edit.html"
+ permission="zope2.Public"
+ class=".browser.ComplexSchemaView"
+ />
+
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IObject"
+ provides="zope.app.form.interfaces.IInputWidget"
+ factory="zope.app.form.browser.objectwidget.ObjectWidget"
+ permission="zope.Public"
+ />
+
<!-- With a widget override -->
<browser:editform
schema=".interfaces.IFieldSimpleContent"
Modified: z3/Five/trunk/tests/products/FiveTest/fancycontent.py
==============================================================================
--- z3/Five/trunk/tests/products/FiveTest/fancycontent.py (original)
+++ z3/Five/trunk/tests/products/FiveTest/fancycontent.py Mon Apr 18 14:55:08 2005
@@ -4,7 +4,8 @@
from Globals import InitializeClass
from zope.interface import implements
-from interfaces import IFancyContent
+from interfaces import IFancyContent, IComplexSchemaContent
+from simplecontent import FieldSimpleContent
class FancyAttribute(Acquisition.Explicit):
"""Doc test fanatics"""
@@ -44,3 +45,20 @@
"""Add the fancy fancy content."""
id = self._setObject(id, FancyContent(id))
return ''
+
+class ComplexSchemaContent(SimpleItem):
+
+ implements(IComplexSchemaContent)
+
+ def __init__(self, id):
+ self.id = id
+ self.fish = FieldSimpleContent('fish', 'title')
+ self.fish.description = ""
+ self.fishtype = 'Lost fishy'
+
+InitializeClass(FancyContent)
+
+def manage_addComplexSchemaContent(self, id, REQUEST=None):
+ """Add the fancy fancy content."""
+ id = self._setObject(id, ComplexSchemaContent(id))
+ return ''
Modified: z3/Five/trunk/tests/products/FiveTest/interfaces.py
==============================================================================
--- z3/Five/trunk/tests/products/FiveTest/interfaces.py (original)
+++ z3/Five/trunk/tests/products/FiveTest/interfaces.py Mon Apr 18 14:55:08 2005
@@ -1,5 +1,5 @@
from zope.interface import Interface
-from zope.schema import Text, TextLine
+from zope.schema import Text, TextLine, Object
class IAdaptable(Interface):
"""This is a Zope 3 interface.
@@ -49,3 +49,19 @@
description=u"A long description of the event.",
default=u"",
required=False)
+
+
+class IComplexSchemaContent(Interface):
+
+ fishtype = TextLine(
+ title=u"Fish type",
+ description=u"The type of fish",
+ default=u"It was a lovely little fish. And it went wherever I did go.",
+ required=False)
+
+ fish = Object(
+ title=u"Fish",
+ schema=IFieldSimpleContent,
+ description=u"The fishy object",
+ required=True)
+
Modified: z3/Five/trunk/tests/test_editform.py
==============================================================================
--- z3/Five/trunk/tests/test_editform.py (original)
+++ z3/Five/trunk/tests/test_editform.py Mon Apr 18 14:55:08 2005
@@ -10,6 +10,7 @@
from Products.Five.tests.products.FiveTest.simplecontent import manage_addFieldSimpleContent
from Products.Five.tests.products.FiveTest.helpers import manage_addFiveTraversableFolder
+from Products.Five.tests.products.FiveTest.fancycontent import manage_addComplexSchemaContent
class EditFormTest(Functional, FiveTestCase):
@@ -60,6 +61,11 @@
self.assertEquals('FooTitle', self.folder.alpha.title)
self.assertEquals('FooDescription', self.folder.alpha.description)
+ def test_objectWidget(self):
+ manage_addComplexSchemaContent(self.folder, 'csc')
+ response = self.publish('/test_folder_1_/csc/edit.html',
+ basic='manager:r00t')
+ self.assertEquals(200, response.getStatus())
def test_suite():
from unittest import TestSuite, makeSuite
More information about the z3-checkins
mailing list