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

Fred L. Drake, Jr. fred@zope.com
Thu, 12 Dec 2002 14:38:56 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	test_schema.py 
Log Message:
Add test with several layers of nested sections.


=== Packages/ZConfig/tests/test_schema.py 1.1.2.9 => 1.1.2.10 ===
--- Packages/ZConfig/tests/test_schema.py:1.1.2.9	Thu Dec 12 14:26:46 2002
+++ Packages/ZConfig/tests/test_schema.py	Thu Dec 12 14:38:55 2002
@@ -134,6 +134,38 @@
         self.assert_(conf.s1 is not None)
         self.assert_(conf.s2 is not None)
 
+    def test_deeply_nested_sections(self):
+        schema = self.load_schema_text(
+            "<schema>"
+            "  <sectiontype name='type1'>"
+            "    <key name='key'><default>type1-value</default></key>"
+            "    </sectiontype>"
+            "  <sectiontype name='type2'>"
+            "    <key name='key'><default>type2-value</default></key>"
+            "    <section name='sect' type='type1'/>"
+            "    </sectiontype>"
+            "  <sectiontype name='type3'>"
+            "    <key name='key'><default>type3-value</default></key>"
+            "    <section name='sect' type='type2'/>"
+            "    </sectiontype>"
+            "  <section name='sect' type='type3'/>"
+            "</schema>")
+        conf = self.load_config_text(schema,
+                                     "<type3 sect>\n"
+                                     "  key sect3-value\n"
+                                     "  <type2 sect>\n"
+                                     "    key sect2-value\n"
+                                     "    <type1 sect/>\n"
+                                     "  </type2>\n"
+                                     "</type3>")
+        eq = self.assertEqual
+        eq(conf.sect.sect.sect.key, "type1-value")
+        eq(len(conf.sect.sect.sect), 1)
+        eq(conf.sect.sect.key, "sect2-value")
+        eq(len(conf.sect.sect), 2)
+        eq(conf.sect.key, "sect3-value")
+        eq(len(conf.sect), 2)
+
     def test_multivalued_keys(self):
         schema = self.load_schema_text(
             "<schema>"