[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Forms/Views/Browser/tests - SchemaTestObject.py:1.5 testFormView.py:1.10

Stephan Richter srichter@cbu.edu
Fri, 19 Jul 2002 09:13:01 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/Forms/Views/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv24805/lib/python/Zope/App/Forms/Views/Browser/tests

Modified Files:
	SchemaTestObject.py testFormView.py 
Log Message:
Okay, I finished the Forms work. Schema and Forms completely replace the
old Formulator code now. I have switched all the Content objects to using
Schema + Forms; especially the SQL Script has an interesting demo on how
to write your custom fields.

However, I am not satisfied with all my design decisions. There is still
a lot of work to be done in Converters and Widgets. Please contact Martijn
and/or me if you would like to help.


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/SchemaTestObject.py 1.4 => 1.5 ===
     if request is None:
         request = TestBrowserRequest({})
 
-    object = TestObject(id=1, title="Test", creator="srichter@cbu.edu",
+    object = TestObject(id=5, title="Test", creator="strichter@yahoo.com",
                         data="Some data")
     return Edit(object, request)


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/tests/testFormView.py 1.9 => 1.10 ===
 """
 $Id$
 """
+from cStringIO import StringIO
 from unittest import TestCase, TestSuite, main, makeSuite
 from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
 
@@ -36,7 +37,8 @@
         viewService.provideView(IStr, 'widget', IBrowserView, [TextWidget])
         request = SchemaTestObject.TestBrowserRequest(
             {'field_id': '1', 'field_title': 'Test New',
-             'field_creator': 'srichter@cbu.edu', 'field_data': 'Data'})
+             'field_creator': 'srichter@cbu.edu',
+             'field_data': StringIO('Data')})
         self._form = SchemaTestObject.EditFactory(request=request)
         
     def getViewService(self):
@@ -103,10 +105,13 @@
 
     def testGetAllRawFieldData(self):
         data = self._form.getAllRawFieldData()
-        result = {'data': 'Data', 'id': '1', 'title': 'Test New',
+        result = {'data': StringIO('Data'), 'id': '1', 'title': 'Test New',
                   'creator': 'srichter@cbu.edu'}
         for field in data.keys():
-            self.assertEqual(result[field.id], data[field])
+            if field.id == 'data':
+                self.assertEqual(result[field.id].read(), data[field].read())
+            else:
+                self.assertEqual(result[field.id], data[field])
 
 
     def testConvertAllFieldData(self):
@@ -136,6 +141,8 @@
     def testSaveValuesInContect(self):
         data = self._form.getAllRawFieldData()
         data = self._form.convertAllFieldData(data)
+        # The StrinIO must be reloaded.
+        self.setUp()
         self._form.saveValuesInContext()
         obj = self._form.context
         for field in data.keys():