[Zope3-checkins] CVS: Zope3/lib/python/Schema/tests - testSchema.py:1.9
Martijn Faassen
m.faassen@vet.uu.nl
Wed, 4 Sep 2002 09:44:54 -0400
Update of /cvs-repository/Zope3/lib/python/Schema/tests
In directory cvs.zope.org:/tmp/cvs-serv31848/python/Schema/tests
Modified Files:
testSchema.py
Log Message:
Refactored Forms (and Schema).
* A FormView now specifies a single schema explicitly as the 'schema'
(class) attribute. A schema is simply an interface with Field attributes
on it.
* The FormView code now uses the Schema package more for its own
implementation, instead of trying to reimplement things itself.
* got rid of the 'id' attribute for fields. Fields now already know what
name they have, because of the Interface package setting __name__.
Use getName() to get the field name.
=== Zope3/lib/python/Schema/tests/testSchema.py 1.8 => 1.9 ===
--- Zope3/lib/python/Schema/tests/testSchema.py:1.8 Thu Jul 25 18:09:30 2002
+++ Zope3/lib/python/Schema/tests/testSchema.py Wed Sep 4 09:44:23 2002
@@ -19,27 +19,26 @@
ValidationErrorsAll
from Interface import Interface
from Schema import Str
-from Schema import validateMapping, validateMappingAll, ErrorNames
+from Schema import validateMapping, validateMappingAll, getFields, ErrorNames
class ISchemaTest(Interface):
- title = Str(id="title",
- title="Title",
- description="Title",
- default="",
- required=1)
-
- description = Str(id="description",
- title="Description",
- description="Description",
- default="",
- required=1)
-
- spam = Str(id="spam",
- title="Spam",
- description="Spam",
- default="",
- required=1)
-
+ title = Str(
+ title="Title",
+ description="Title",
+ default="",
+ required=1)
+
+ description = Str(
+ title="Description",
+ description="Description",
+ default="",
+ required=1)
+
+ spam = Str(
+ title="Spam",
+ description="Spam",
+ default="",
+ required=1)
class SchemaTest(TestCase):
@@ -79,6 +78,17 @@
return
self.fail('Expected ValidationErrors, but none detected')
+ def test_getFields(self):
+ fields = getFields(ISchemaTest)
+
+ self.assert_(fields.has_key('title'))
+ self.assert_(fields.has_key('description'))
+ self.assert_(fields.has_key('spam'))
+
+ # test whether getName() has the right value
+ for key, value in fields.iteritems():
+ self.assertEquals(key, value.getName())
+
def test_suite():
return makeSuite(SchemaTest)