[Zodb-checkins] CVS: Packages/ZConfig/tests - test_schema.py:1.1.2.5
Fred L. Drake, Jr.
fred@zope.com
Wed, 11 Dec 2002 17:38:50 -0500
Update of /cvs-repository/Packages/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv9381
Modified Files:
Tag: zconfig-schema-devel-branch
test_schema.py
Log Message:
Add test of user-defined datatype.
=== Packages/ZConfig/tests/test_schema.py 1.1.2.4 => 1.1.2.5 ===
--- Packages/ZConfig/tests/test_schema.py:1.1.2.4 Wed Dec 11 17:26:49 2002
+++ Packages/ZConfig/tests/test_schema.py Wed Dec 11 17:38:49 2002
@@ -23,6 +23,11 @@
from ZConfig.tests.test_config import CONFIG_BASE
+class uppercase:
+ def convert(self, value):
+ return str(value).upper()
+
+
class SchemaTestCase(unittest.TestCase):
# tests
@@ -51,6 +56,36 @@
check(not conf.false_var_1)
check(not conf.false_var_2)
check(not conf.false_var_3)
+
+ def test_app_datatype(self):
+ dtname = __name__ + ".uppercase"
+ schema = self.load_schema_text(
+ "<schema>"
+ " <key name='a' type='%s'/>"
+ " <key name='b' type='%s'>"
+ " <default>abc</default>"
+ " </key>"
+ " <key name='c' type='%s' maxOccurs='3'>"
+ " <default>abc</default>"
+ " <default>abc</default>"
+ " </key>"
+ " <key name='d' type='%s' maxOccurs='3'>"
+ " <default>not</default>"
+ " <default>lower</default>"
+ " <default>case</default>"
+ " </key>"
+ "</schema>"
+ % (dtname, dtname, dtname, dtname))
+ conf = self.load_config_text(schema,
+ "a qwerty\n"
+ "c upp\n"
+ "c er \n"
+ "c case\n")
+ eq = self.assertEqual
+ eq(conf.a, 'QWERTY')
+ eq(conf.b, 'ABC')
+ eq(conf.c, ['UPP', 'ER', 'CASE'])
+ eq(conf.d, ['NOT', 'LOWER', 'CASE'])
def test_multivalued_keys(self):
schema = self.load_schema_text(