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

Fred L. Drake, Jr. fred@zope.com
Thu, 2 Jan 2003 18:07:03 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	test_schema.py 
Log Message:
Make sure we support an anonymous simple section, and a simple section
which allows any name (but not anonymous sections).


=== Packages/ZConfig/tests/test_schema.py 1.1.2.34 => 1.1.2.35 ===
--- Packages/ZConfig/tests/test_schema.py:1.1.2.34	Tue Dec 31 17:07:05 2002
+++ Packages/ZConfig/tests/test_schema.py	Thu Jan  2 18:06:59 2003
@@ -422,6 +422,33 @@
         conf.empty = new
         self.assert_(conf[0] is new)
 
+    def test_simple_anonymous_section(self):
+        schema = self.load_schema_text(
+            "<schema>"
+            "  <sectiontype type='sect'>"
+            "    <key name='key' default='value'/>"
+            "  </sectiontype>"
+            "  <section name='*' type='sect' attribute='attr'/>"
+            "</schema>")
+        conf = self.load_config_text(schema, "<sect/>")
+        self.assertEqual(conf.attr.key, "value")
+
+    def test_simple_anynamed_section(self):
+        schema = self.load_schema_text(
+            "<schema>"
+            "  <sectiontype type='sect'>"
+            "    <key name='key' default='value'/>"
+            "  </sectiontype>"
+            "  <section name='+' type='sect' attribute='attr'/>"
+            "</schema>")
+        conf = self.load_config_text(schema, "<sect name/>")
+        self.assertEqual(conf.attr.key, "value")
+        self.assertEqual(conf.attr.__name__, "name")
+
+        # if we omit the name, it's an error
+        self.assertRaises(ZConfig.ConfigurationError,
+                          self.load_config_text, schema, "<sect/>")
+
 
 def test_suite():
     return unittest.makeSuite(SchemaTestCase)