[Zodb-checkins] CVS: Packages/ZConfig/tests - test_schema.py:1.15

Fred L. Drake, Jr. fred@zope.com
Mon, 24 Feb 2003 12:21:56 -0500


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

Modified Files:
	test_schema.py 
Log Message:
Add a test that checks certain aspects of using specialized keytypes.


=== Packages/ZConfig/tests/test_schema.py 1.14 => 1.15 ===
--- Packages/ZConfig/tests/test_schema.py:1.14	Wed Feb 19 10:54:15 2003
+++ Packages/ZConfig/tests/test_schema.py	Mon Feb 24 12:21:55 2003
@@ -691,6 +691,31 @@
         self.assertRaises(ZConfig.ConfigurationError,
                           self.load_config_text, schema, "abc.  127.0.0.1")
 
+    def test_keytype_identifier(self):
+        schema = self.load_schema_text("""\
+           <schema keytype='identifier'>
+             <key name='foo' attribute='foo'/>
+             <key name='Foo' attribute='Foo'/>
+           </schema>
+           """)
+        conf = self.load_config_text(schema,
+                                     "Foo Foo-value\n"
+                                     "foo foo-value\n")
+        self.assertEqual(conf.foo, "foo-value")
+        self.assertEqual(conf.Foo, "Foo-value")
+        # key mis-match based on case:
+        self.assertRaises(ZConfig.ConfigurationError,
+                          self.load_config_text, schema, "FOO frob\n")
+        # attribute names conflict, since the keytype isn't used to
+        # generate attribute names
+        self.assertRaises(ZConfig.SchemaError,
+                          self.load_schema_text, """\
+                          <schema keytype='identifier'>
+                            <key name='foo'/>
+                            <key name='Foo'/>
+                          </schema>
+                          """)
+
     def test_datatype_casesensitivity(self):
         self.load_schema_text("<schema datatype='NULL'/>")