[Zope-Checkins] CVS: Packages/ZConfig/tests - test_loader.py:1.1.2.5

Fred L. Drake, Jr. fred@zope.com
Thu, 2 Jan 2003 10:42:57 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	test_loader.py 
Log Message:
Several more fixes for the URL helper functions, with improved tests.

=== Packages/ZConfig/tests/test_loader.py 1.1.2.4 => 1.1.2.5 ===
--- Packages/ZConfig/tests/test_loader.py:1.1.2.4	Thu Jan  2 09:50:43 2003
+++ Packages/ZConfig/tests/test_loader.py	Thu Jan  2 10:42:55 2003
@@ -76,18 +76,41 @@
         eq(url.urldefrag("zconfig:abc/def.ghi"),
            ("zconfig:abc/def.ghi", ''))
 
-    def test_urlsplit(self):
+    def test_urlsplit_absolute(self):
         parts = url.urlsplit("zconfig:path/to/resource/file.txt#fragment")
         self.assertEqual(parts, ("zconfig", '', "path/to/resource/file.txt",
                                  '', "fragment"))
-        parts = url.urlsplit("path/to/resource/file.txt#fragment", "zconfig")
-        self.assertEqual(parts, ('', '', "path/to/resource/file.txt",
-                                 '', "fragment"))
         self.assertRaises(ValueError, url.urlsplit, "zconfig://host")
         self.assertRaises(ValueError, url.urlsplit, "zconfig:host?query")
 
-        s = url.urljoin("zconfig:path/file.txt#oldfrag", "../newpath/foo.xml")
-        self.assertEqual(s, "zconfig:newpath/foo.xml")
+    def test_urlsplit_relative(self):
+        eq = self.assertEqual
+        raises = self.assertRaises
+
+        def urlsplit(s):
+            return url.urlsplit(s, scheme="zconfig")
+
+        eq(urlsplit("#frag"),
+           ('zconfig', '', '', '', "frag"))
+        eq(urlsplit("path/to/resource#frag"),
+           ('zconfig', '', "path/to/resource", '', "frag"))
+        eq(url.urlsplit("path/to/resource/file.txt#fragment", "zconfig"),
+           ('zconfig', '', "path/to/resource/file.txt", '', "fragment"))
+
+        raises(ValueError, urlsplit, "/path/to/resource")
+        raises(ValueError, urlsplit, "/path/to/resource?query")
+        raises(ValueError, urlsplit, "path/to/resource?query")
+
+    def test_urljoin(self):
+        eq = self.assertEqual
+        eq(url.urljoin("zconfig:path/file.txt#oldfrag", "../newpath/foo.xml"),
+           "zconfig:newpath/foo.xml")
+        eq(url.urljoin("zconfig:abc.xml", "def.xml"),
+           "zconfig:def.xml")
+        eq(url.urljoin("zconfig:abc.xml", "#frag"),
+           "zconfig:abc.xml#frag")
+        self.assertRaises(ValueError, url.urljoin,
+                          "zconfig:abc.xml", "../def.xml")
 
 
 def test_suite():