[Zope3-checkins] CVS: Zope3/src/ZConfig/tests - test_loader.py:1.16

Fred L. Drake, Jr. fred@zope.com
Thu, 10 Jul 2003 14:40:16 -0400


Update of /cvs-repository/Zope3/src/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv4271/tests

Modified Files:
	test_loader.py 
Log Message:
Added "file" attribute to the "import" element; this allows a package to
provide more than one ZConfig schema component.


=== Zope3/src/ZConfig/tests/test_loader.py 1.15 => 1.16 ===
--- Zope3/src/ZConfig/tests/test_loader.py:1.15	Thu Jul 10 11:32:22 2003
+++ Zope3/src/ZConfig/tests/test_loader.py	Thu Jul 10 14:39:40 2003
@@ -76,6 +76,31 @@
         schema = loader.loadFile(sio)
         self.assert_(schema.gettype("widget-a") is not None)
 
+    def test_import_from_package_with_file(self):
+        loader = ZConfig.loader.SchemaLoader()
+        sio = StringIO("<schema>"
+                       "  <import package='ZConfig.tests.library.widget'"
+                       "          file='extra.xml' />"
+                       "</schema>")
+        schema = loader.loadFile(sio)
+        self.assert_(schema.gettype("extra-type") is not None)
+
+    def test_import_from_package_with_missing_file(self):
+        loader = ZConfig.loader.SchemaLoader()
+        sio = StringIO("<schema>"
+                       "  <import package='ZConfig.tests.library.widget'"
+                       "          file='notthere.xml' />"
+                       "</schema>")
+        self.assertRaises(ZConfig.SchemaError, loader.loadFile, sio)
+
+    def test_import_from_package_with_directory_file(self):
+        loader = ZConfig.loader.SchemaLoader()
+        sio = StringIO("<schema>"
+                       "  <import package='ZConfig.tests.library.widget'"
+                       "          file='really/notthere.xml' />"
+                       "</schema>")
+        self.assertRaises(ZConfig.SchemaError, loader.loadFile, sio)
+
     def test_urlsplit_urlunsplit(self):
         # Extracted from Python's test.test_urlparse module:
         for url, parsed, split in [