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

Fred L. Drake, Jr. fred@zope.com
Tue, 24 Dec 2002 13:36:15 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	test_schema.py 
Log Message:
Add some utility functions to make examining a schema a little easier.

=== Packages/ZConfig/tests/test_schema.py 1.1.2.31 => 1.1.2.32 ===
--- Packages/ZConfig/tests/test_schema.py:1.1.2.31	Fri Dec 20 17:32:31 2002
+++ Packages/ZConfig/tests/test_schema.py	Tue Dec 24 13:36:12 2002
@@ -387,6 +387,34 @@
                           "  <key name='+' attribute='attr2'/>"
                           "</schema>")
 
+    def test_getrequiredtypes(self):
+        schema = self.load_schema("library.xml")
+        self.assertEqual(schema.getrequiredtypes(), [])
+
+        schema = self.load_schema_text(
+            "<schema type='top'>"
+            "  <sectiontype type='used'/>"
+            "  <sectiontype type='unused'/>"
+            "  <section type='used' name='a'/>"
+            "</schema>")
+        L = schema.getrequiredtypes()
+        L.sort()
+        self.assertEqual(L, ["top", "used"])
+
+    def test_getunusedtypes(self):
+        schema = self.load_schema("library.xml")
+        L = schema.getunusedtypes()
+        L.sort()
+        self.assertEqual(L, ["type-a", "type-b"])
+
+        schema = self.load_schema_text(
+            "<schema type='top'>"
+            "  <sectiontype type='used'/>"
+            "  <sectiontype type='unused'/>"
+            "  <section type='used' name='a'/>"
+            "</schema>")
+        self.assertEqual(schema.getunusedtypes(), ["unused"])
+
 
 def test_suite():
     return unittest.makeSuite(SchemaTestCase)