[Zope3-checkins] CVS: Packages/ZConfig/tests - test_schema.py:1.1.2.38
Fred L. Drake, Jr.
fred@zope.com
Fri, 3 Jan 2003 12:05:26 -0500
Update of /cvs-repository/Packages/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv12732/tests
Modified Files:
Tag: zconfig-schema-devel-branch
test_schema.py
Log Message:
Allow a sectiontype to extend an existing group.
This is needed to allow schema components to themselves be extensible (for
example, to add new concrete storage types to an abstract "storage" type).
=== Packages/ZConfig/tests/test_schema.py 1.1.2.37 => 1.1.2.38 ===
--- Packages/ZConfig/tests/test_schema.py:1.1.2.37 Fri Jan 3 00:50:42 2003
+++ Packages/ZConfig/tests/test_schema.py Fri Jan 3 12:05:22 2003
@@ -342,6 +342,40 @@
self.assert_(conf.g[2]._type is t2)
self.assert_(conf.g[3]._type is t2)
+ def test_sectiongroup_extension(self):
+ schema = self.load_schema_text(
+ "<schema>"
+ " <sectiongroup type='group'/>"
+ " <sectiontype type='extra' group='group'/>"
+ " <section name='thing' type='group'/>"
+ "</schema>")
+ group = schema.gettype("group")
+ self.assert_(schema.gettype("extra") is group.gettype("extra"))
+
+ # make sure we can use the extension in a config:
+ conf = self.load_config_text(schema, "<extra thing/>")
+ self.assertEqual(conf.thing.getSectionType(), "extra")
+
+ def test_sectiongroup_extension_errors(self):
+ # specifying a non-existant group
+ self.assertRaises(ZConfig.SchemaError, self.load_schema_text,
+ "<schema>"
+ " <sectiontype type='s' group='group'/>"
+ "</schema>")
+ # specifying something that isn't a group
+ self.assertRaises(ZConfig.SchemaError, self.load_schema_text,
+ "<schema>"
+ " <sectiontype type='t1'/>"
+ " <sectiontype type='t2' group='t1'/>"
+ "</schema>")
+ # specifying a group from w/in a group
+ self.assertRaises(ZConfig.SchemaError, self.load_schema_text,
+ "<schema>"
+ " <sectiongroup type='group'>"
+ " <sectiontype type='t' group='group'/>"
+ " </sectiongroup>"
+ "</schema>")
+
def test_arbitrary_key(self):
schema = self.load_schema_text(
"<schema>"