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

Fred L. Drake, Jr. fred@zope.com
Thu, 19 Dec 2002 12:36:19 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	test_schema.py 
Log Message:
More tests checking support for arbitrary keys.


=== Packages/ZConfig/tests/test_schema.py 1.1.2.27 => 1.1.2.28 ===
--- Packages/ZConfig/tests/test_schema.py:1.1.2.27	Thu Dec 19 11:51:27 2002
+++ Packages/ZConfig/tests/test_schema.py	Thu Dec 19 12:36:18 2002
@@ -326,6 +326,27 @@
         conf = self.load_config_text(schema, "some-key 42\n some-key 43")
         self.assertEqual(conf.keymap, {'some-key': [42, 43]})
 
+    def test_arbitrary_keys_with_others(self):
+        schema = self.load_schema_text(
+            "<schema>"
+            "  <key name='k1' default='v1'/>"
+            "  <key name='k2' default='2' datatype='integer'/>"
+            "  <key name='+' required='yes' attribute='keymap'"
+            "       datatype='integer'/>"
+            "</schema>")
+        conf = self.load_config_text(schema, "some-key 42 \n k2 3")
+        self.assertEqual(conf.k1, 'v1')
+        self.assertEqual(conf.k2, 3)
+        self.assertEqual(conf.keymap, {'some-key': 42})
+
+    def test_arbitrary_key_missing(self):
+        schema = self.load_schema_text(
+            "<schema>"
+            "  <key name='+' required='yes' attribute='keymap' />"
+            "</schema>")
+        self.assertRaises(ZConfig.ConfigurationError,
+                          self.load_config_text, schema, "# empty config file")
+
     def test_arbitrary_key_bad_schema(self):
         self.assertRaises(ZConfig.SchemaError,
                           self.load_schema_text,