Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
CMFDefault.tests.test_Document.DocumentFTPGetTests Class Reference
Inheritance diagram for CMFDefault.tests.test_Document.DocumentFTPGetTests:
Inheritance graph
[legend]
Collaboration diagram for CMFDefault.tests.test_Document.DocumentFTPGetTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def testHTML
def testSTX

Public Attributes

 site

Detailed Description

Definition at line 375 of file test_Document.py.


Member Function Documentation

Definition at line 377 of file test_Document.py.

00377 
00378     def setUp(self):
00379         RequestTest.setUp(self)
00380         self.site = DummySite('site').__of__(self.root)

Definition at line 381 of file test_Document.py.

00381 
00382     def testHTML( self ):
00383         self.REQUEST['BODY']=BASIC_HTML
00384 
00385         ttool = self.site._setObject( 'portal_types', TypesTool() )
00386         fti = FTIDATA_CMF15[0].copy()
00387         del fti['id']
00388         ttool._setObject( 'Document', FTI('Document', **fti) )
00389 
00390         zpt = self.site._setObject( 'source_html',
00391                                     ZopePageTemplate('source_html') )
00392         dir = abspath( dirname(utils.__file__) )
00393         _file = path_join(dir, 'skins', 'zpt_content', 'source_html.pt')
00394         data = open(_file, 'r').read()
00395         zpt.write(data)
00396 
00397         d = self._makeOne('foo')
00398         d._setPortalTypeName('Document')
00399         d.PUT(self.REQUEST, self.RESPONSE)
00400 
00401         rnlinesplit = compile( r'\r?\n?' )
00402         simple_lines = rnlinesplit.split( BASIC_HTML )
00403         get_lines = rnlinesplit.split( d.manage_FTPget() )
00404 
00405         # strip off headers
00406         meta_pattern = compile( r'meta name="([a-z]*)" '
00407                                  + r'content="([a-z]*)"'
00408                                  )
00409         title_pattern = compile( r'<title>(.*)</title>' )
00410         simple_headers = []
00411         while simple_lines and simple_lines[0] != '<BODY>':
00412             header = simple_lines[0].strip().lower()
00413             match = meta_pattern.search( header )
00414             if match:
00415                 simple_headers.append( match.groups() )
00416             else:
00417                 match = title_pattern.search( header )
00418                 if match:
00419                     simple_headers.append( ( 'title', match.group(1) ) )
00420             simple_lines = simple_lines[1:]
00421 
00422         get_headers = []
00423         while get_lines and get_lines[0] != '<BODY>':
00424             header = get_lines[0].strip().lower()
00425             match = meta_pattern.search( header )
00426             if match:
00427                 get_headers.append( match.groups() )
00428             else:
00429                 match = title_pattern.search( header )
00430                 if match:
00431                     get_headers.append( ( 'title', match.group(1) ) )
00432             get_lines = get_lines[1:]
00433 
00434         self.assertEqual( get_lines, simple_lines )
00435 
00436         self.failUnless( get_headers )
00437         self.failUnless( simple_headers )
00438         self.failUnless( len( get_headers ) >= len( simple_headers ) )
00439 
00440         for header in simple_headers:
00441             self.failUnless( header in get_headers )
00442 
00443         body1 = d.EditableBody()
00444         self.REQUEST['BODY'] = d.manage_FTPget()
00445         d.PUT(self.REQUEST, self.RESPONSE)
00446         self.assertEqual( d.EditableBody(), body1 )

Definition at line 447 of file test_Document.py.

00447 
00448     def testSTX( self ):
00449         self.REQUEST['BODY']=SIMPLE_STRUCTUREDTEXT
00450         d = self._makeOne('foo')
00451         d.PUT(self.REQUEST, self.RESPONSE)
00452 
00453         rnlinesplit = compile( r'\r?\n?' )
00454 
00455         get_text = d.manage_FTPget()
00456         simple_lines = rnlinesplit.split( SIMPLE_STRUCTUREDTEXT )
00457         get_lines = rnlinesplit.split( get_text )
00458 
00459         # strip off headers
00460         simple_headers = []
00461         while simple_lines and simple_lines[0]:
00462             simple_headers.append( simple_lines[0] )
00463             simple_lines = simple_lines[1:]
00464 
00465         get_headers = []
00466         while get_lines and get_lines[0]:
00467             get_headers.append( get_lines[0] )
00468             get_lines = get_lines[1:]
00469 
00470         self.assertEqual( get_lines, simple_lines )
00471 
00472         for header in simple_headers:
00473             self.failUnless( header in get_headers )
00474 


Member Data Documentation

Definition at line 379 of file test_Document.py.


The documentation for this class was generated from the following file: