[Checkins] SVN: z3c.form/trunk/src/z3c/form/ some coverage happiness, found these lying around
Adam Groszer
agroszer at gmail.com
Fri Mar 27 13:30:44 EDT 2009
Log message for revision 98426:
some coverage happiness, found these lying around
Changed:
U z3c.form/trunk/src/z3c/form/browser/multi.txt
U z3c.form/trunk/src/z3c/form/widget.txt
-=-
Modified: z3c.form/trunk/src/z3c/form/browser/multi.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/multi.txt 2009-03-27 15:02:41 UTC (rev 98425)
+++ z3c.form/trunk/src/z3c/form/browser/multi.txt 2009-03-27 17:30:43 UTC (rev 98426)
@@ -478,7 +478,7 @@
</div>
<input type="hidden" name="widget.name.count" value="2" />
-Error handling is next. Let's use teh value "bad" (an invalid integer literal)
+Error handling is next. Let's use the value "bad" (an invalid integer literal)
as input for our internal (sub) widget.
>>> from z3c.form.error import ErrorViewSnippet
@@ -601,7 +601,7 @@
</div>
<input type="hidden" name="widget.name.count" value="1" />
-Now, with middle-length sequence. All buttons should be there.
+Now, with middle-length sequence. All buttons should be there.
>>> widget.request = TestRequest(form={'widget.name.count':u'2',
... 'widget.name.0':u'42',
@@ -1037,4 +1037,87 @@
</div>
</div>
<input type="hidden" name="None.count" value="2" />
-
\ No newline at end of file
+
+
+Coverage happiness
+------------------
+
+
+
+ >>> field = zope.schema.List(
+ ... __name__=u'foo',
+ ... value_type=zope.schema.Int(title=u'Number'),
+ ... )
+ >>> request = TestRequest()
+ >>> widget = multi.MultiWidget(request)
+ >>> widget.field = field
+ >>> widget.id = 'widget-id'
+ >>> widget.name = 'widget.name'
+ >>> widget.widgets = []
+ >>> widget.value = []
+
+ >>> widget.request = TestRequest()
+ >>> widget.update()
+
+ >>> widget.value = [u'42', u'43', u'44']
+ >>> widget.value = [u'99']
+
+ >>> print widget.render()
+ <html>
+ <body>
+ <div class="multi-widget">
+ <div class="row" id="widget-id-0-row">
+ <div class="label">
+ <label for="widget-id-0">
+ <span>Number</span>
+ <span class="required">*</span>
+ </label>
+ </div>
+ <div class="widget">
+ <div class="multi-widget-checkbox">
+ <input class="multi-widget-checkbox checkbox-widget" id="widget-id-0-remove" name="widget.name.0.remove" type="checkbox" value="1">
+ </div>
+ <div class="multi-widget-input">
+ <input class="text-widget required int-field" id="widget-id-0" name="widget.name.0" type="text" value="99">
+ </div>
+ </div>
+ </div>
+ <div class="row" id="widget-id-1-row">
+ <div class="label">
+ <label for="widget-id-1">
+ <span>Number</span>
+ <span class="required">*</span>
+ </label>
+ </div>
+ <div class="widget">
+ <div class="multi-widget-checkbox">
+ <input class="multi-widget-checkbox checkbox-widget" id="widget-id-1-remove" name="widget.name.1.remove" type="checkbox" value="1">
+ </div>
+ <div class="multi-widget-input">
+ <input class="text-widget required int-field" id="widget-id-1" name="widget.name.1" type="text" value="">
+ </div>
+ </div>
+ </div>
+ <div class="row" id="widget-id-2-row">
+ <div class="label">
+ <label for="widget-id-2">
+ <span>Number</span>
+ <span class="required">*</span>
+ </label>
+ </div>
+ <div class="widget">
+ <div class="multi-widget-checkbox">
+ <input class="multi-widget-checkbox checkbox-widget" id="widget-id-2-remove" name="widget.name.2.remove" type="checkbox" value="1">
+ </div>
+ <div class="multi-widget-input">
+ <input class="text-widget required int-field" id="widget-id-2" name="widget.name.2" type="text" value="">
+ </div>
+ </div>
+ </div>
+ <div class="buttons">
+ <input class="submit-widget button-field" id="widget-name-buttons-add" name="widget.name.buttons.add" type="submit" value="Add">
+ </div>
+ </div>
+ <input name="widget.name.count" type="hidden" value="3">
+ </body>
+ </html>
Modified: z3c.form/trunk/src/z3c/form/widget.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/widget.txt 2009-03-27 15:02:41 UTC (rev 98425)
+++ z3c.form/trunk/src/z3c/form/widget.txt 2009-03-27 17:30:43 UTC (rev 98426)
@@ -544,8 +544,6 @@
is required for processing the input from a request. The counter is a marker
for build the right amount of enumerated widgets.
-If we provide an empty counter we will get no value:
-
If we provide no request we will get no value:
>>> multiWidget.extract()
@@ -595,8 +593,8 @@
the right amount of (sub) widgets by the given counter value. Based on that
counter value the right amount of widgets will get created. Each widget will
return it's own value and this collected values get returned by the extract
-method. The multi widget update method will then store this values if any give
-as multi widget value argument. If extract doesnt return a value the multi
+method. The multi widget update method will then store this values if any given
+as multi widget value argument. If extract doesn't return a value the multi
widget update method will use it's default value. If we store a given value
from the extract as multi widget value, this will force to setup the multi
widget widgets based on the given values and apply the right value for them.
@@ -616,6 +614,13 @@
[]
>>> multiWidget.update()
+
+ >>> multiWidget.widgets[0].value
+ u'42'
+
+ >>> multiWidget.widgets[1].value
+ u'43'
+
>>> multiWidget.value
[u'42', u'43']
@@ -715,4 +720,3 @@
>>> import os
>>> os.remove(textWidgetTemplate)
-
More information about the Checkins
mailing list