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

Fred L. Drake, Jr. fred@zope.com
Tue, 7 Jan 2003 01:27:15 -0500


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

Modified Files:
	test_loader.py 
Log Message:
Very preliminary implementation of a schema component library.
Not ready for deployment.


=== Packages/ZConfig/tests/test_loader.py 1.4 => 1.5 ===
--- Packages/ZConfig/tests/test_loader.py:1.4	Fri Jan  3 17:38:30 2003
+++ Packages/ZConfig/tests/test_loader.py	Tue Jan  7 01:27:11 2003
@@ -13,6 +13,8 @@
 ##############################################################################
 """Tests of ZConfig.loader classes and helper functions."""
 
+import os.path
+import sys
 import unittest
 
 from StringIO import StringIO
@@ -25,6 +27,15 @@
 from ZConfig.tests.test_config import CONFIG_BASE
 
 
+try:
+    myfile = __file__
+except NameError:
+    myfile = sys.argv[0]
+
+myfile = os.path.abspath(myfile)
+LIBRARY_DIR = os.path.join(os.path.dirname(myfile), "library")
+
+
 class LoaderTestCase(unittest.TestCase):
 
     def test_schema_caching(self):
@@ -67,6 +78,25 @@
                                    "  <import src='library.xml'"
                                    "          package='ZConfig'/>"
                                    "</schema>"))
+
+    def test_import_from_package(self):
+        loader = ZConfig.loader.SchemaLoader(library=LIBRARY_DIR)
+        sio = StringIO("<schema>"
+                       "  <import package='widget'/>"
+                       "</schema>")
+        schema = loader.loadFile(sio)
+        self.assert_(schema.gettype("widget-a") is not None)
+
+    def xxx_test_import_from_package_extended(self):
+        loader = ZConfig.loader.SchemaLoader(library=LIBRARY_DIR)
+        sio = StringIO("<schema>"
+                       "  <import package='thing'/>"
+                       "</schema>")
+        schema = loader.loadFile(sio)
+        self.assert_(schema.gettype("thing-a") is not None)
+        self.assert_(schema.gettype("thing-b") is not None)
+        self.assert_(schema.gettype("thing-ext") is not None)
+        self.assert_(schema.gettype("thing"))
 
 
 def test_suite():