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

Fred L. Drake, Jr. fred@zope.com
Fri, 3 Jan 2003 13:07:13 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	test_loader.py 
Log Message:
Start support for configuration packages.  This will be needed to allow
schema extensions to be installed by third-party packages (such as
DirectoryStorage).

The meat of it is not there, but some of the framework and checks are in,
with the relevant tests added.


=== Packages/ZConfig/tests/test_loader.py 1.1.2.5 => 1.1.2.6 ===
--- Packages/ZConfig/tests/test_loader.py:1.1.2.5	Thu Jan  2 10:42:55 2003
+++ Packages/ZConfig/tests/test_loader.py	Fri Jan  3 13:07:10 2003
@@ -13,10 +13,11 @@
 ##############################################################################
 """Tests of ZConfig.loader classes and helper functions."""
 
-import StringIO
 import unittest
 import urlparse
 
+from StringIO import StringIO
+
 import ZConfig
 import ZConfig.loader
 
@@ -46,17 +47,27 @@
         self.assert_(type_a is schema.gettype("type-a"))
         self.assert_(type_b is schema.gettype("type-b"))
 
-    def test_simple_import(self):
+    def test_simple_import_with_cache(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>")
+        sio = 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_import_errors(self):
+        # must specify exactly one of package or src
+        self.assertRaises(ZConfig.SchemaError, ZConfig.loadSchemaFile,
+                          StringIO("<schema><import/></schema>"))
+        self.assertRaises(ZConfig.SchemaError, ZConfig.loadSchemaFile,
+                          StringIO("<schema>"
+                                   "  <import src='library.xml'"
+                                   "          package='ZConfig'/>"
+                                   "</schema>"))
 
     def test_zconfig_resource(self):
         loader = ZConfig.loader.SchemaLoader()