[CMF-checkins] CVS: CMF/CMFDefault/tests - test_Document.py:1.19.2.2 test_Link.py:1.2.2.2

Tres Seaver tseaver@zope.com
Tue, 8 Jan 2002 13:25:57 -0500


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

Modified Files:
      Tag: CMF-1_2-branch
	test_Document.py test_Link.py 
Log Message:
 - Merge fix for Tracker #407 from branch.

=== CMF/CMFDefault/tests/test_Document.py 1.19.2.1 => 1.19.2.2 ===
         d.PUT(REQUEST, RESPONSE=fakeResponse())
 
-        simple_lines = string.split( SIMPLE_HTML, '\n' )
-        get_lines = string.split( d.manage_FTPget(), '\n' )
+        rnlinesplit = re.compile( r'\r?\n?' )
+        simple_lines = rnlinesplit.split( SIMPLE_HTML )
+        get_lines = rnlinesplit.split( d.manage_FTPget() )
 
         # strip off headers
         meta_pattern = re.compile( r'meta name="([a-z]*)" '
@@ -408,8 +409,11 @@
         d = Document( 'foo' )
         d.PUT(REQUEST, RESPONSE=fakeResponse())
 
-        simple_lines = string.split( SIMPLE_STRUCTUREDTEXT, '\n' )
-        get_lines = string.split( d.manage_FTPget(), '\n' )
+        rnlinesplit = re.compile( r'\r?\n?' )
+
+        get_text = d.manage_FTPget()
+        simple_lines = rnlinesplit.split( SIMPLE_STRUCTUREDTEXT )
+        get_lines = rnlinesplit.split( get_text )
 
         # strip off headers
         simple_headers = []


=== CMF/CMFDefault/tests/test_Link.py 1.2.2.1 => 1.2.2.2 ===
+import unittest, string, re
 from Products.CMFDefault.Link import Link
 
 BASIC_STRUCTUREDTEXT = '''\
@@ -9,27 +9,45 @@
 http://www.zope.org
 '''
 
-class LinkTests(unittest.TestCase):
+STX_W_CONTINUATION = '''\
+Title: Zope Community
+Description: Link to the Zope Community website,
+  including hundreds of contributed Zope products.
+Subject: open source; Zope; community
 
-    def setUp( self ):
-        get_transaction().begin()
+http://www.zope.org
+'''
 
-    def tearDown( self ):
-        get_transaction().abort()
+class LinkTests(unittest.TestCase):
 
     def test_Empty( self ):
         d = Link( 'foo' )
-        self.failUnless( d.Title() == '' )
-        self.failUnless( d.Description() == '' )
-        self.failUnless( d.getRemoteUrl() == '' )
+        self.assertEqual( d.Title(), '' )
+        self.assertEqual( d.Description(), '' )
+        self.assertEqual( d.getRemoteUrl(), '' )
 
     def test_StructuredText( self ):
         d = Link('foo')
         d._writeFromPUT( body=BASIC_STRUCTUREDTEXT )
         
         self.assertEqual( d.Title(), 'Zope Community' )
-        self.assertEqual(
-                d.Description(), 'Link to the Zope Community website.' )
+        self.assertEqual( d.Description()
+                        , 'Link to the Zope Community website.' )
+        self.assertEqual( len(d.Subject()), 3 )
+        self.assertEqual( d.getRemoteUrl(), 'http://www.zope.org' )
+
+    def test_StructuredText_w_Continuation( self ):
+
+        d = Link('foo')
+        d._writeFromPUT( body=STX_W_CONTINUATION )
+        rnlinesplit = re.compile( r'\r?\n?' )
+        desc_lines = rnlinesplit.split( d.Description() )
+        
+        self.assertEqual( d.Title(), 'Zope Community' )
+        self.assertEqual( desc_lines[0]
+                        , 'Link to the Zope Community website,' )
+        self.assertEqual( desc_lines[1]
+                        , 'including hundreds of contributed Zope products.' )
         self.assertEqual( len(d.Subject()), 3 )
         self.assertEqual( d.getRemoteUrl(), 'http://www.zope.org' )