[Zope3-checkins] CVS: Packages/ZConfig/tests - test_schema.py:1.1.2.21

Fred L. Drake, Jr. fred@zope.com
Fri, 13 Dec 2002 16:56:35 -0500


Update of /cvs-repository/Packages/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv24930

Modified Files:
      Tag: zconfig-schema-devel-branch
	test_schema.py 
Log Message:
More tests of the handler machinery.


=== Packages/ZConfig/tests/test_schema.py 1.1.2.20 => 1.1.2.21 ===
--- Packages/ZConfig/tests/test_schema.py:1.1.2.20	Fri Dec 13 16:32:47 2002
+++ Packages/ZConfig/tests/test_schema.py	Fri Dec 13 16:56:34 2002
@@ -172,7 +172,7 @@
     def test_multivalued_keys(self):
         schema = self.load_schema_text(
             "<schema handler='def'>"
-            "  <key name='a' minOccurs='2' maxOccurs='5' handler='abc' />"
+            "  <key name='a' minOccurs='2' maxOccurs='5' handler='ABC' />"
             "  <key name='b' minOccurs='2' maxOccurs='2' datatype='integer'>"
             "    <default>1</default>"
             "    <default>2</default>"
@@ -195,10 +195,27 @@
         self.handlers({'abc': L.append,
                        'DEF': L.append})
         self.assertEqual(L, [['foo', 'bar'], conf])
+        L = []
+        self.handlers({'abc': None,
+                       'DEF': L.append})
+        self.assertEqual(L, [conf])
         self.assertEqual(conf.a, ['foo', 'bar'])
         self.assertEqual(conf.b, [1, 2])
         self.assertEqual(conf.c, [41, 42, 43])
         self.assertEqual(conf.d, [])
+
+    def test_bad_handler_maps(self):
+        schema = self.load_schema_text(
+            "<schema>"
+            "  <key name='a' handler='abc'/>"
+            "  <key name='b' handler='def'/>"
+            "</schema>")
+        conf = self.load_config_text(schema, "a foo\n b bar",
+                                     num_handlers=2)
+        self.assertRaises(ZConfig.ConfigurationError,
+                          self.handlers, {'abc': id, 'ABC': id, 'def': id})
+        self.assertRaises(ZConfig.ConfigurationError,
+                          self.handlers, {})
 
     def test_duplicate_section_names(self):
         schema = self.load_schema_text(