[Zodb-checkins] CVS: Zope3/src/ZConfig/tests - test_schema.py:1.19
Phillip J. Eby
pje at telecommunity.com
Fri Oct 3 16:37:40 EDT 2003
Update of /cvs-repository/Zope3/src/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv7880/tests
Modified Files:
test_schema.py
Log Message:
Added <schema extends=""> feature, w/docs and tests.
=== Zope3/src/ZConfig/tests/test_schema.py 1.18 => 1.19 ===
--- Zope3/src/ZConfig/tests/test_schema.py:1.18 Thu May 1 15:34:57 2003
+++ Zope3/src/ZConfig/tests/test_schema.py Fri Oct 3 16:37:09 2003
@@ -17,7 +17,7 @@
import ZConfig
-from ZConfig.tests.support import TestBase
+from ZConfig.tests.support import TestBase, CONFIG_BASE
def uppercase(value):
@@ -44,6 +44,9 @@
def test_simple(self):
schema, conf = self.load_both("simple.xml", "simple.conf")
+ self._verifySimpleConf(conf)
+
+ def _verifySimpleConf(self,conf):
eq = self.assertEqual
eq(conf.var1, 'abc')
eq(conf.int_var, 12)
@@ -709,6 +712,59 @@
def test_datatype_casesensitivity(self):
self.load_schema_text("<schema datatype='NULL'/>")
+ def test_simple_extends(self):
+ schema = self.load_schema_text("""\
+ <schema extends="%s/simple.xml %s/library.xml">
+ <section name="A" type="type-a" />
+ </schema>
+ """ % (CONFIG_BASE,CONFIG_BASE))
+ self._verifySimpleConf(self.load_config(schema, "simple.conf"))
+
+ def test_extends_fragment_failure(self):
+ self.assertRaises(ZConfig.SchemaError,
+ self.load_schema_text, """\
+ <schema extends="%s/library.xml#foo" />
+ """ % CONFIG_BASE)
+
+ def test_multi_extends_implicit_OK(self):
+ schema = self.load_schema_text("""\
+ <schema extends="%s/base.xml %s/library.xml">
+ <section name="A" type="type-a" />
+ <section name="X" type="type-X" />
+ </schema>
+ """ % (CONFIG_BASE,CONFIG_BASE))
+
+ def test_multi_extends_explicit_datatype_OK(self):
+ schema = self.load_schema_text("""\
+ <schema extends="%s/base-datatype1.xml %s/base-datatype2.xml"
+ datatype="null">
+ <section name="One" type="type-1" />
+ <section name="Two" type="type-2" />
+ </schema>
+ """ % (CONFIG_BASE,CONFIG_BASE))
+
+
+ def test_multi_extends_explicit_keytype_OK(self):
+ schema = self.load_schema_text("""\
+ <schema extends="%s/base-keytype1.xml %s/base-keytype2.xml"
+ keytype="%s.uppercase">
+ <section name="One" type="type-1" />
+ <section name="Two" type="type-2" />
+ </schema>
+ """ % (CONFIG_BASE,CONFIG_BASE,__name__))
+
+
+ def test_multi_extends_datatype_conflict(self):
+ self.assertRaises(ZConfig.SchemaError,
+ self.load_schema_text, """\
+ <schema extends="%s/base-datatype1.xml %s/base-datatype2.xml"/>
+ """ % (CONFIG_BASE,CONFIG_BASE))
+
+ def test_multi_extends_keytype_conflict(self):
+ self.assertRaises(ZConfig.SchemaError,
+ self.load_schema_text, """\
+ <schema extends="%s/base-keytype1.xml %s/base-keytype2.xml"/>
+ """ % (CONFIG_BASE,CONFIG_BASE))
def test_suite():
return unittest.makeSuite(SchemaTestCase)
More information about the Zodb-checkins
mailing list