def testSTX( self ): self.REQUEST['BODY']=SIMPLE_STRUCTUREDTEXT d = Document( 'foo' ) d.PUT(self.REQUEST, self.RESPONSE) rnlinesplit = 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 = [] while simple_lines and simple_lines[0]: simple_headers.append( simple_lines[0] ) simple_lines = simple_lines[1:] get_headers = [] while get_lines and get_lines[0]: get_headers.append( get_lines[0] ) get_lines = get_lines[1:] self.assertEqual( get_lines, simple_lines ) for header in simple_headers: self.failUnless( header in get_headers )
def testSTX(self): self.REQUEST['BODY'] = SIMPLE_STRUCTUREDTEXT d = Document('foo') d.PUT(self.REQUEST, self.RESPONSE) rnlinesplit = 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 = [] while simple_lines and simple_lines[0]: simple_headers.append(simple_lines[0]) simple_lines = simple_lines[1:] get_headers = [] while get_lines and get_lines[0]: get_headers.append(get_lines[0]) get_lines = get_lines[1:] self.assertEqual(get_lines, simple_lines) for header in simple_headers: self.failUnless(header in get_headers)
def testHTML( self ): REQUEST=fakeRequest() REQUEST['BODY']=SIMPLE_HTML d = Document( 'foo' ) d.PUT(REQUEST, RESPONSE=fakeResponse()) 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]*)" ' + r'content="([a-z]*)"' ) title_pattern = re.compile( r'<title>(.*)</title>' ) simple_headers = [] while simple_lines and simple_lines[0] != '<BODY>': header = string.lower( string.strip( simple_lines[0] ) ) match = meta_pattern.search( header ) if match: simple_headers.append( match.groups() ) else: match = title_pattern.search( header ) if match: simple_headers.append( ( 'title', match.group(1) ) ) simple_lines = simple_lines[1:] get_headers = [] while get_lines and get_lines[0] != '<BODY>': header = string.lower( string.strip( get_lines[0] ) ) match = meta_pattern.search( header ) if match: get_headers.append( match.groups() ) else: match = title_pattern.search( header ) if match: get_headers.append( ( 'title', match.group(1) ) ) get_lines = get_lines[1:] self.assertEqual( get_lines, simple_lines ) self.failUnless( get_headers ) self.failUnless( simple_headers ) self.failUnless( len( get_headers ) >= len( simple_headers ) ) for header in simple_headers: self.failUnless( header in get_headers )
def testHTML( self ): self.REQUEST['BODY']=BASIC_HTML d = Document( 'foo' ) d.PUT(self.REQUEST, self.RESPONSE) rnlinesplit = compile( r'\r?\n?' ) simple_lines = rnlinesplit.split( BASIC_HTML ) get_lines = rnlinesplit.split( d.manage_FTPget() ) # strip off headers meta_pattern = compile( r'meta name="([a-z]*)" ' + r'content="([a-z]*)"' ) title_pattern = compile( r'<title>(.*)</title>' ) simple_headers = [] while simple_lines and simple_lines[0] != '<BODY>': header = simple_lines[0].strip().lower() match = meta_pattern.search( header ) if match: simple_headers.append( match.groups() ) else: match = title_pattern.search( header ) if match: simple_headers.append( ( 'title', match.group(1) ) ) simple_lines = simple_lines[1:] get_headers = [] while get_lines and get_lines[0] != '<BODY>': header = get_lines[0].strip().lower() match = meta_pattern.search( header ) if match: get_headers.append( match.groups() ) else: match = title_pattern.search( header ) if match: get_headers.append( ( 'title', match.group(1) ) ) get_lines = get_lines[1:] self.assertEqual( get_lines, simple_lines ) self.failUnless( get_headers ) self.failUnless( simple_headers ) self.failUnless( len( get_headers ) >= len( simple_headers ) ) for header in simple_headers: self.failUnless( header in get_headers )
def testHTML(self): REQUEST = fakeRequest() REQUEST['BODY'] = SIMPLE_HTML d = Document('foo') d.PUT(REQUEST, RESPONSE=fakeResponse()) simple_lines = string.split(SIMPLE_HTML, '\n') get_lines = string.split(d.manage_FTPget(), '\n') # strip off headers meta_pattern = re.compile(r'meta name="([a-z]*)" ' + r'content="([a-z]*)"') title_pattern = re.compile(r'<title>(.*)</title>') simple_headers = [] while simple_lines and simple_lines[0] != '<BODY>': header = string.lower(string.strip(simple_lines[0])) match = meta_pattern.search(header) if match: simple_headers.append(match.groups()) else: match = title_pattern.search(header) if match: simple_headers.append(('title', match.group(1))) simple_lines = simple_lines[1:] get_headers = [] while get_lines and get_lines[0] != '<BODY>': header = string.lower(string.strip(get_lines[0])) match = meta_pattern.search(header) if match: get_headers.append(match.groups()) else: match = title_pattern.search(header) if match: get_headers.append(('title', match.group(1))) get_lines = get_lines[1:] assert get_lines == simple_lines assert get_headers assert simple_headers assert len(get_headers) >= len(simple_headers) for header in simple_headers: assert header in get_headers, [header, get_headers]
def testSTX( self ): REQUEST=fakeRequest() REQUEST['BODY']=SIMPLE_STRUCTUREDTEXT d = Document( 'foo' ) d.PUT(REQUEST, RESPONSE=fakeResponse()) simple_lines = string.split( SIMPLE_STRUCTUREDTEXT, '\n' ) get_lines = string.split( d.manage_FTPget(), '\n' ) # strip off headers simple_headers = [] while simple_lines and simple_lines[0]: simple_headers.append( simple_lines[0] ) simple_lines = simple_lines[1:] get_headers = [] while get_lines and get_lines[0]: get_headers.append( get_lines[0] ) get_lines = get_lines[1:] assert get_lines == simple_lines for header in simple_headers: assert header in get_headers, [header, get_headers]
def testSTX(self): REQUEST = fakeRequest() REQUEST['BODY'] = SIMPLE_STRUCTUREDTEXT d = Document('foo') d.PUT(REQUEST, RESPONSE=fakeResponse()) simple_lines = string.split(SIMPLE_STRUCTUREDTEXT, '\n') get_lines = string.split(d.manage_FTPget(), '\n') # strip off headers simple_headers = [] while simple_lines and simple_lines[0]: simple_headers.append(simple_lines[0]) simple_lines = simple_lines[1:] get_headers = [] while get_lines and get_lines[0]: get_headers.append(get_lines[0]) get_lines = get_lines[1:] assert get_lines == simple_lines for header in simple_headers: assert header in get_headers, [header, get_headers]