[Zope3-checkins] CVS: Packages/ZConfig/tests - test_loader.py:1.1.2.2

Fred L. Drake, Jr. fred@zope.com
Mon, 23 Dec 2002 11:22:29 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	test_loader.py 
Log Message:
Simple type import mechanism to allow schema components to be re-used.

=== Packages/ZConfig/tests/test_loader.py 1.1.2.1 => 1.1.2.2 ===
--- Packages/ZConfig/tests/test_loader.py:1.1.2.1	Mon Dec 23 10:57:13 2002
+++ Packages/ZConfig/tests/test_loader.py	Mon Dec 23 11:21:58 2002
@@ -13,6 +13,7 @@
 ##############################################################################
 """Tests of ZConfig.loader classes."""
 
+import StringIO
 import unittest
 import urlparse
 
@@ -39,8 +40,21 @@
         type_b = loader.loadURL(url + "#type-b")
         self.assertEqual(type_a.name, "type-a")
         self.assertEqual(type_b.name, "type-b")
+        # make sure we're using the cached schema for the types
         self.assert_(type_a is schema.gettype("type-a"))
         self.assert_(type_b is schema.gettype("type-b"))
+
+    def test_simple_import(self):
+        loader = ZConfig.loader.SchemaLoader()
+        url1 = urlparse.urljoin(CONFIG_BASE, "library.xml")
+        schema1 = loader.loadURL(url1)
+        sio = StringIO.StringIO("<schema>"
+                                "  <import src='library.xml'/>"
+                                "  <section type='type-a' name='section'/>"
+                                "</schema>")
+        url2 = urlparse.urljoin(CONFIG_BASE, "stringio")
+        schema2 = loader.loadFile(sio, url2)
+        self.assert_(schema1.gettype("type-a") is schema2.gettype("type-a"))
 
 
 def test_suite():