add datetime form test stable
authorFlorent <florent@secondweb.fr>
Tue, 23 Jun 2009 12:12:34 +0200
branchstable
changeset 2145 529867c301fc
parent 2115 c48ff1d0acc4
child 2146 6645e18e8c93
add datetime form test
web/test/unittest_form.py
--- a/web/test/unittest_form.py	Thu Jun 18 09:38:32 2009 +0200
+++ b/web/test/unittest_form.py	Tue Jun 23 12:12:34 2009 +0200
@@ -6,6 +6,8 @@
 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
 """
 
+from xml.etree.ElementTree import fromstring
+
 from logilab.common.testlib import unittest_main, mock_object
 
 from cubicweb import Binary
@@ -13,7 +15,7 @@
 from cubicweb.web.formfields import (IntField, StringField, RichTextField,
                                      DateTimeField, DateTimePicker,
                                      FileField, EditableFileField)
-from cubicweb.web.formwidgets import PasswordInput
+from cubicweb.web.formwidgets import PasswordInput, Input
 from cubicweb.web.views.forms import EntityFieldsForm, FieldsForm
 from cubicweb.web.views.workflow import ChangeStateForm
 from cubicweb.web.views.formrenderers import FormRenderer
@@ -210,5 +212,13 @@
 <span class="emphasis">confirm password</span>''' % {'eid': self.entity.eid})
 
 
+    def test_datefield(self):
+        class DFForm(EntityFieldsForm):
+            creation_date = DateTimeField(widget=Input)
+        form = DFForm(self.req, entity=self.entity)
+        init, cur = (fromstring(self._render_entity_field(attr, form)).get('value')
+                     for attr in ('edits-creation_date', 'creation_date'))
+        self.assertEquals(init, cur)
+
 if __name__ == '__main__':
     unittest_main()