Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_xmlrpc.CGIHandlerTestCase Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_cgi_get
def test_cgi_xmlrpc_response

Public Attributes

 cgi

Detailed Description

Definition at line 866 of file test_xmlrpc.py.


Member Function Documentation

Definition at line 867 of file test_xmlrpc.py.

Here is the caller graph for this function:

Definition at line 870 of file test_xmlrpc.py.

00870 
00871     def tearDown(self):
00872         self.cgi = None

Here is the caller graph for this function:

Definition at line 873 of file test_xmlrpc.py.

00873 
00874     def test_cgi_get(self):
00875         with support.EnvironmentVarGuard() as env:
00876             env['REQUEST_METHOD'] = 'GET'
00877             # if the method is GET and no request_text is given, it runs handle_get
00878             # get sysout output
00879             with captured_stdout(encoding=self.cgi.encoding) as data_out:
00880                 self.cgi.handle_request()
00881 
00882             # parse Status header
00883             data_out.seek(0)
00884             handle = data_out.read()
00885             status = handle.split()[1]
00886             message = ' '.join(handle.split()[2:4])
00887 
00888             self.assertEqual(status, '400')
00889             self.assertEqual(message, 'Bad Request')
00890 

Here is the call graph for this function:

Definition at line 891 of file test_xmlrpc.py.

00891 
00892     def test_cgi_xmlrpc_response(self):
00893         data = """<?xml version='1.0'?>
00894         <methodCall>
00895             <methodName>test_method</methodName>
00896             <params>
00897                 <param>
00898                     <value><string>foo</string></value>
00899                 </param>
00900                 <param>
00901                     <value><string>bar</string></value>
00902                 </param>
00903             </params>
00904         </methodCall>
00905         """
00906 
00907         with support.EnvironmentVarGuard() as env, \
00908              captured_stdout(encoding=self.cgi.encoding) as data_out, \
00909              support.captured_stdin() as data_in:
00910             data_in.write(data)
00911             data_in.seek(0)
00912             env['CONTENT_LENGTH'] = str(len(data))
00913             self.cgi.handle_request()
00914         data_out.seek(0)
00915 
00916         # will respond exception, if so, our goal is achieved ;)
00917         handle = data_out.read()
00918 
00919         # start with 44th char so as not to get http header, we just
00920         # need only xml
00921         self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, handle[44:])
00922 
00923         # Also test the content-length returned  by handle_request
00924         # Using the same test method inorder to avoid all the datapassing
00925         # boilerplate code.
00926         # Test for bug: http://bugs.python.org/issue5040
00927 
00928         content = handle[handle.find("<?xml"):]
00929 
00930         self.assertEqual(
00931             int(re.search('Content-Length: (\d+)', handle).group(1)),
00932             len(content))
00933 
00934 
@support.reap_threads

Here is the call graph for this function:


Member Data Documentation

Definition at line 868 of file test_xmlrpc.py.


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