[CMF-checkins] CVS: CMF/CMFDefault/tests - test_Link.py:1.6

Florent Guillaume fg@nuxeo.com
Sat, 29 Jun 2002 15:35:07 -0400


Update of /cvs-repository/CMF/CMFDefault/tests
In directory cvs.zope.org:/tmp/cvs-serv7039/CMFDefault/tests

Modified Files:
	test_Link.py 
Log Message:
Made the Link objects deal correctly with empty remote urls
(Tracker #507) and not strip trailing slashes (Tracker #451).

I corrected the behavior and testcase that said that 'baz.com' was
canonicalized into 'http://baz.com', which was dubious, as I'd rather
have 'baz.html' canonicalized into 'http:baz.html'.

This is a change of behavior that may be unwanted however.


=== CMF/CMFDefault/tests/test_Link.py 1.5 => 1.6 ===
         self.assertEqual( d.URL_FORMAT, 'text/url')
 
+        d = Link('foo', remote_url='bar')
+        d.edit('')
+        self.assertEqual(d.getRemoteUrl(), '')
+
     def test_StructuredText( self ):
         d = Link('foo')
         d._writeFromPUT( body=BASIC_STRUCTUREDTEXT )
@@ -67,8 +71,30 @@
         self.assertEqual( d.getRemoteUrl(), 'http://bar.com' )
 
         d = Link( 'baz' )
-        d.edit( 'baz.com' )
-        self.assertEqual( d.getRemoteUrl(), 'http://baz.com' )
+        d.edit( 'baz.html' )
+        self.assertEqual( d.getRemoteUrl(), 'http:baz.html' )
+
+        d = Link( 'zoinx' )
+        d.edit( '/huh/zoinx.html' )
+        self.assertEqual( d.getRemoteUrl(), 'http:/huh/zoinx.html' )
+
+        d = Link( 'lol' )
+        d.edit( 'hmmm/lol.txt' )
+        self.assertEqual( d.getRemoteUrl(), 'http:hmmm/lol.txt' )
+
+    def test_trailingSlash(self):
+        d = Link('foo', remote_url='http://foo.com/bar/')
+        self.assertEqual(d.getRemoteUrl(), 'http://foo.com/bar/')
+
+        d = Link('foo', remote_url='baz/')
+        self.assertEqual(d.getRemoteUrl(), 'http:baz/')
+
+        d = Link('foo', remote_url='/baz/zoinx/')
+        self.assertEqual(d.getRemoteUrl(), 'http:/baz/zoinx/')
+
+        d = Link('foo')
+        d.edit('/baz/foo/')
+        self.assertEqual(d.getRemoteUrl(), 'http:/baz/foo/')
 
 
 def test_suite():