[CMF-checkins] CVS: Products/CMFDefault/tests - test_Document.py:1.21 test_Link.py:1.3
Tres Seaver
tseaver@zope.com
Tue, 8 Jan 2002 13:21:12 -0500
Update of /cvs-repository/Products/CMFDefault/tests
In directory cvs.zope.org:/tmp/cvs-serv4154/CMFDefault/tests
Modified Files:
test_Document.py test_Link.py
Log Message:
- Merge fix for Tracker #407 from branch.
=== Products/CMFDefault/tests/test_Document.py 1.20 => 1.21 ===
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 = []
=== Products/CMFDefault/tests/test_Link.py 1.2 => 1.3 ===
+import unittest, string, re
from Products.CMFDefault.Link import Link
BASIC_STRUCTUREDTEXT = '''\
@@ -9,42 +9,60 @@
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.failUnless( d.Title() == 'Zope Community' )
- self.failUnless(
- d.Description() == 'Link to the Zope Community website.' )
- self.failUnless( len(d.Subject()) == 3 )
- self.failUnless( d.getRemoteUrl() == 'http://www.zope.org' )
+ self.assertEqual( d.Title(), 'Zope Community' )
+ 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' )
def test_fixupMissingScheme( self ):
d = Link( 'foo' )
d.edit( 'http://foo.com' )
- self.failUnless( d.getRemoteUrl() == 'http://foo.com' )
+ self.assertEqual( d.getRemoteUrl(), 'http://foo.com' )
d = Link( 'bar' )
d.edit( '//bar.com' )
- self.failUnless( d.getRemoteUrl() == 'http://bar.com' )
+ self.assertEqual( d.getRemoteUrl(), 'http://bar.com' )
d = Link( 'baz' )
d.edit( 'baz.com' )
- self.failUnless( d.getRemoteUrl() == 'http://baz.com' )
+ self.assertEqual( d.getRemoteUrl(), 'http://baz.com' )