Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
ResourceRegistries.tests.testHTTPHeaders.TestHTTPHeaders Class Reference
Inheritance diagram for ResourceRegistries.tests.testHTTPHeaders.TestHTTPHeaders:
Inheritance graph
[legend]
Collaboration diagram for ResourceRegistries.tests.testHTTPHeaders.TestHTTPHeaders:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def testContentTypeHeaders
def testIfModifiedSinceHeaders
def testContentLengthHeaders

Public Attributes

 tool
 toolpath
 portalpath

Detailed Description

Definition at line 18 of file testHTTPHeaders.py.


Member Function Documentation

Definition at line 20 of file testHTTPHeaders.py.

00020 
00021     def afterSetUp(self):
00022         self.tool = getattr(self.portal, CSSTOOLNAME)
00023         self.tool.clearResources()
00024         self.toolpath = '/' + self.tool.absolute_url(1)
00025         self.portalpath = '/' + getToolByName(self.portal, 'portal_url')(1)

Definition at line 60 of file testHTTPHeaders.py.

00060 
00061     def testContentLengthHeaders(self):
00062         # Test that the main page retains its content-type
00063         self.setRoles(['Manager'])
00064 
00065         request = self.portal.REQUEST
00066         request.environ['IF_MODIFIED_SINCE'] = rfc1123_date((DateTime() - 60.0/(24.0*3600.0))) # if modified in the last minute
00067         #print self.portal.REQUEST.get_header('If-Modified-Since')
00068         self.tool.registerStylesheet('test_rr_1.css')
00069         self.portal.addDTMLMethod('testmethod', file="""/* YES WE ARE RENDERED */""")
00070         self.tool.registerStylesheet('testmethod')
00071         self.portal.addDTMLMethod('testmethod2', file="""/* YES WE ARE RENDERED 2 */""")
00072         self.tool.registerStylesheet('testmethod2')
00073         # we also add an fsfile for good measure
00074         self.tool.registerStylesheet('test_rr_2.css')
00075         rs = self.tool.getEvaluatedResources(self.portal)
00076         self.assertEqual(len(rs),1)
00077         response = self.publish(self.toolpath+'/'+rs[0].getId())
00078         self.assertEqual(response.getHeader('Content-Type'), 'text/css;charset=utf-8')
00079         #print str(response)
00080         self.assertEqual(int(response.getHeader('content-length')), len(response.getBody()))
00081         self.assertEqual(response.getStatus(), 200)
00082 

Here is the call graph for this function:

Definition at line 26 of file testHTTPHeaders.py.

00026 
00027     def testContentTypeHeaders(self):
00028         # Test that the main page retains its content-type
00029         self.setRoles(['Manager'])
00030         # we make a method that tries to set its own Content-Type headers
00031         self.portal.addDTMLMethod('testmethod', file="""<dtml-call "REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain')">""")
00032         self.tool.registerStylesheet('testmethod')
00033         response = self.publish(self.toolpath+'/testmethod')
00034         self.assertEqual(response.getHeader('Content-Type'), 'text/css;charset=utf-8')
00035         self.assertEqual(response.getStatus(), 200)

Here is the call graph for this function:

Definition at line 36 of file testHTTPHeaders.py.

00036 
00037     def testIfModifiedSinceHeaders(self):
00038         # Test that the main page returns the proper status code and content type for a conditional get
00039         self.setRoles(['Manager'])
00040         request = self.portal.REQUEST
00041         request.environ['IF_MODIFIED_SINCE'] = rfc1123_date((DateTime() - 60.0/(24.0*3600.0))) # resend if modified since one minute ago (assumes client clock is a little slow)
00042         assert request.get_header('If-Modified-Since')
00043         self.portal.addDTMLMethod('testmethod', file="""/* YES WE ARE RENDERED */""")
00044         self.tool.registerStylesheet('testmethod')
00045         response = self.publish(self.toolpath+'/testmethod', env={'IF_MODIFIED_SINCE': rfc1123_date((DateTime() - 60.0/(24.0*3600.0)))})
00046         #response = self.publish(self.toolpath+'/testmethod')
00047         self.assertEqual(response.getHeader('Content-Type'), 'text/css;charset=utf-8')
00048         self.assertEqual(response.getStatus(), 200) # this should in fact send a 200
00049 
00050         # we also add an fsfile for good measure
00051         self.tool.registerStylesheet('test_rr_2.css')
00052         rs = self.tool.getEvaluatedResources(self.portal)
00053         response = self.publish(self.toolpath+'/test_rr_2.css', env={'IF_MODIFIED_SINCE': rfc1123_date((DateTime() - 60.0/(24.0*3600.0)))})
00054         self.assertEqual(response.getStatus(), 200)  # this should send a 200 when things are fixed, but right now should send a 304
00055         self.assertEqual(response.getHeader('Content-Type'), 'text/css;charset=utf-8')
00056 
00057         #response = self.publish(self.toolpath+'/test_rr_2.css')
00058         #self.assertEqual(response.getStatus(), 200)  # this should send a 200 when things are fixed, but right now should send a 304
00059 

Here is the call graph for this function:


Member Data Documentation

Definition at line 24 of file testHTTPHeaders.py.

Definition at line 21 of file testHTTPHeaders.py.

Definition at line 23 of file testHTTPHeaders.py.


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