[Checkins] SVN: z3ext.layout/trunk/src/z3ext/layout/ update tests

Nikolay Kim fafhrd at datacom.kz
Tue Dec 9 13:14:25 EST 2008


Log message for revision 93822:
  update tests

Changed:
  U   z3ext.layout/trunk/src/z3ext/layout/pagelet.txt
  U   z3ext.layout/trunk/src/z3ext/layout/zcml.txt

-=-
Modified: z3ext.layout/trunk/src/z3ext/layout/pagelet.txt
===================================================================
--- z3ext.layout/trunk/src/z3ext/layout/pagelet.txt	2008-12-09 16:58:09 UTC (rev 93821)
+++ z3ext.layout/trunk/src/z3ext/layout/pagelet.txt	2008-12-09 18:14:25 UTC (rev 93822)
@@ -143,6 +143,31 @@
   ...
   ZopeXMLConfigurationError: ...Required field is missing...number...
 
+Schema can provide default value
+
+  >>> class INewPagelet2(interface.Interface):
+  ...     """New pagelet interface."""
+  ...     
+  ...     number = schema.Int(
+  ...         title = u'Number',
+  ...         required = False,
+  ...         default = 9)
+
+  >>> context = xmlconfig.string("""
+  ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+  ...   <z3ext:pagelet
+  ...       name="new.html"
+  ...       class="z3ext.layout.TESTS.NewPagelet"
+  ...       permission="zope.Public"
+  ...       provides="z3ext.layout.TESTS.INewPagelet2" />
+  ... </configure>
+  ... """, context)
+
+  >>> pagelet = component.getMultiAdapter(
+  ...     (object(), TestRequest()), INewPagelet2, name='new.html')
+  >>> print pagelet.number
+  9
+
 Let's provide 'number' in directive
 
   >>> context = xmlconfig.string("""
@@ -177,7 +202,30 @@
   ...
   ZopeXMLConfigurationError: ...invalid literal for int()...
 
+Schema field should implement IFromUnicode 
 
+  >>> class INewPagelet3(interface.Interface):
+  ...     
+  ...     date = schema.Date(
+  ...         title = u'Date',
+  ...         required = False)
+
+  >>> context = xmlconfig.string("""
+  ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+  ...   <z3ext:pagelet
+  ...       name="new.html"
+  ...       class="z3ext.layout.TESTS.NewPagelet"
+  ...       permission="zope.Public"
+  ...       date="2007-10-10"
+  ...       provides="z3ext.layout.TESTS.INewPagelet3" />
+  ... </configure>
+  ... """, context)
+  Traceback (most recent call last):
+  ...
+  ZopeXMLConfigurationError:...ConfigurationError: ("Can't convert value", 'date')
+
+
+
 We can create pagelet without specific class
 
   >>> context = xmlconfig.string("""

Modified: z3ext.layout/trunk/src/z3ext/layout/zcml.txt
===================================================================
--- z3ext.layout/trunk/src/z3ext/layout/zcml.txt	2008-12-09 16:58:09 UTC (rev 93821)
+++ z3ext.layout/trunk/src/z3ext/layout/zcml.txt	2008-12-09 18:14:25 UTC (rev 93822)
@@ -1,5 +1,5 @@
-
 Just tests
+----------
 
   >>> import tempfile, os.path
   >>> import z3ext.layout
@@ -84,3 +84,38 @@
   ...     class="z3ext.layout.tests.MyLayout"
   ...     template="%s" />
   ... </configure>"""%layoutportal, context)
+
+layout uid
+
+  >>> context = xmlconfig.string("""
+  ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+  ...   <z3ext:layout
+  ...     name="testlayout"
+  ...     uid="test.layout"
+  ...     view="z3ext.layout.tests.IFolder1_1_1"
+  ...     template="%s" />
+  ... </configure>"""%layoutportal, context)
+
+  >>> from zope.component.eventtesting import getEvents
+  >>> ev = getEvents()[-1]
+  >>> print ev
+  <z3ext.layout.zcml.LayoutCreatedEvent ...>
+
+  >>> ev.uid, ev.name, ev.layoutclass
+  (u'test.layout', u'testlayout', <class 'z3ext.layout.zcml.Layout<testlayout>'>)
+
+  >>> context = xmlconfig.string("""
+  ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+  ...   <z3ext:layout
+  ...     name="testlayout"
+  ...     uid="test.layout2"
+  ...     for="z3ext.layout.tests.IFolder1_1_1"
+  ...     template="%s" />
+  ... </configure>"""%layoutportal, context)
+
+  >>> ev = getEvents()[-1]
+  >>> print ev
+  <z3ext.layout.zcml.LayoutCreatedEvent ...>
+
+  >>> ev.uid, ev.name, ev.layoutclass
+  (u'test.layout2', u'testlayout', <class 'z3ext.layout.zcml.Layout<testlayout>'>)



More information about the Checkins mailing list