Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
test.test_xmlrpc.SimpleServerTestCase Class Reference
Inheritance diagram for test.test_xmlrpc.SimpleServerTestCase:
Inheritance graph
[legend]
Collaboration diagram for test.test_xmlrpc.SimpleServerTestCase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_simple1
def test_nonascii
def XXXtest_404
def test_introspection1
def test_introspection2
def test_introspection3
def test_introspection4
def test_multicall
def test_non_existing_multicall
def test_dotted_attribute
def setUp
def tearDown

Public Attributes

 evt

Static Public Attributes

 requestHandler = None
int request_count = 1
tuple threadFunc = staticmethod(http_server)

Detailed Description

Definition at line 449 of file test_xmlrpc.py.


Member Function Documentation

def test.test_xmlrpc.BaseServerTestCase.setUp (   self) [inherited]

Reimplemented in test.test_xmlrpc.GzipServerTestCase, and test.test_xmlrpc.BaseKeepaliveServerTestCase.

Definition at line 424 of file test_xmlrpc.py.

00424 
00425     def setUp(self):
00426         # enable traceback reporting
00427         xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = True
00428 
00429         self.evt = threading.Event()
00430         # start server thread to handle requests
00431         serv_args = (self.evt, self.request_count, self.requestHandler)
00432         threading.Thread(target=self.threadFunc, args=serv_args).start()
00433 
00434         # wait for the server to be ready
00435         self.evt.wait()
00436         self.evt.clear()

Here is the caller graph for this function:

Definition at line 437 of file test_xmlrpc.py.

00437 
00438     def tearDown(self):
00439         # wait on the server thread to terminate
00440         self.evt.wait(4.0)
00441         # XXX this code does not work, and in fact stop_serving doesn't exist.
00442         if not self.evt.is_set():
00443             self.evt.set()
00444             stop_serving()
00445             raise RuntimeError("timeout reached, test has failed")
00446 
00447         # disable traceback reporting
00448         xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = False

Here is the caller graph for this function:

Definition at line 577 of file test_xmlrpc.py.

00577 
00578     def test_dotted_attribute(self):
00579         # Raises an AttributeError because private methods are not allowed.
00580         self.assertRaises(AttributeError,
00581                           xmlrpc.server.resolve_dotted_attribute, str, '__add')
00582 
00583         self.assertTrue(xmlrpc.server.resolve_dotted_attribute(str, 'title'))
00584         # Get the test to run faster by sending a request with test_simple1.
00585         # This avoids waiting for the socket timeout.
00586         self.test_simple1()

Here is the call graph for this function:

Definition at line 485 of file test_xmlrpc.py.

00485 
00486     def test_introspection1(self):
00487         expected_methods = set(['pow', 'div', 'my_function', 'add',
00488                                 'system.listMethods', 'system.methodHelp',
00489                                 'system.methodSignature', 'system.multicall'])
00490         try:
00491             p = xmlrpclib.ServerProxy(URL)
00492             meth = p.system.listMethods()
00493             self.assertEqual(set(meth), expected_methods)
00494         except (xmlrpclib.ProtocolError, socket.error) as e:
00495             # ignore failures due to non-blocking socket 'unavailable' errors
00496             if not is_unavailable_exception(e):
00497                 # protocol error; provide additional information in test output
00498                 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
00499 

Here is the call graph for this function:

Definition at line 500 of file test_xmlrpc.py.

00500 
00501     def test_introspection2(self):
00502         try:
00503             # test _methodHelp()
00504             p = xmlrpclib.ServerProxy(URL)
00505             divhelp = p.system.methodHelp('div')
00506             self.assertEqual(divhelp, 'This is the div function')
00507         except (xmlrpclib.ProtocolError, socket.error) as e:
00508             # ignore failures due to non-blocking socket 'unavailable' errors
00509             if not is_unavailable_exception(e):
00510                 # protocol error; provide additional information in test output
00511                 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))

Here is the call graph for this function:

Definition at line 514 of file test_xmlrpc.py.

00514 
00515     def test_introspection3(self):
00516         try:
00517             # test native doc
00518             p = xmlrpclib.ServerProxy(URL)
00519             myfunction = p.system.methodHelp('my_function')
00520             self.assertEqual(myfunction, 'This is my function')
00521         except (xmlrpclib.ProtocolError, socket.error) as e:
00522             # ignore failures due to non-blocking socket 'unavailable' errors
00523             if not is_unavailable_exception(e):
00524                 # protocol error; provide additional information in test output
00525                 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))

Here is the call graph for this function:

Definition at line 526 of file test_xmlrpc.py.

00526 
00527     def test_introspection4(self):
00528         # the SimpleXMLRPCServer doesn't support signatures, but
00529         # at least check that we can try making the call
00530         try:
00531             p = xmlrpclib.ServerProxy(URL)
00532             divsig = p.system.methodSignature('div')
00533             self.assertEqual(divsig, 'signatures not supported')
00534         except (xmlrpclib.ProtocolError, socket.error) as e:
00535             # ignore failures due to non-blocking socket 'unavailable' errors
00536             if not is_unavailable_exception(e):
00537                 # protocol error; provide additional information in test output
00538                 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))

Here is the call graph for this function:

Definition at line 539 of file test_xmlrpc.py.

00539 
00540     def test_multicall(self):
00541         try:
00542             p = xmlrpclib.ServerProxy(URL)
00543             multicall = xmlrpclib.MultiCall(p)
00544             multicall.add(2,3)
00545             multicall.pow(6,8)
00546             multicall.div(127,42)
00547             add_result, pow_result, div_result = multicall()
00548             self.assertEqual(add_result, 2+3)
00549             self.assertEqual(pow_result, 6**8)
00550             self.assertEqual(div_result, 127//42)
00551         except (xmlrpclib.ProtocolError, socket.error) as e:
00552             # ignore failures due to non-blocking socket 'unavailable' errors
00553             if not is_unavailable_exception(e):
00554                 # protocol error; provide additional information in test output
00555                 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))

Here is the call graph for this function:

Definition at line 556 of file test_xmlrpc.py.

00556 
00557     def test_non_existing_multicall(self):
00558         try:
00559             p = xmlrpclib.ServerProxy(URL)
00560             multicall = xmlrpclib.MultiCall(p)
00561             multicall.this_is_not_exists()
00562             result = multicall()
00563 
00564             # result.results contains;
00565             # [{'faultCode': 1, 'faultString': '<class \'exceptions.Exception\'>:'
00566             #   'method "this_is_not_exists" is not supported'>}]
00567 
00568             self.assertEqual(result.results[0]['faultCode'], 1)
00569             self.assertEqual(result.results[0]['faultString'],
00570                 '<class \'Exception\'>:method "this_is_not_exists" '
00571                 'is not supported')
00572         except (xmlrpclib.ProtocolError, socket.error) as e:
00573             # ignore failures due to non-blocking socket 'unavailable' errors
00574             if not is_unavailable_exception(e):
00575                 # protocol error; provide additional information in test output
00576                 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))

Here is the call graph for this function:

Definition at line 460 of file test_xmlrpc.py.

00460 
00461     def test_nonascii(self):
00462         start_string = 'P\N{LATIN SMALL LETTER Y WITH CIRCUMFLEX}t'
00463         end_string = 'h\N{LATIN SMALL LETTER O WITH HORN}n'
00464         try:
00465             p = xmlrpclib.ServerProxy(URL)
00466             self.assertEqual(p.add(start_string, end_string),
00467                              start_string + end_string)
00468         except (xmlrpclib.ProtocolError, socket.error) as e:
00469             # ignore failures due to non-blocking socket 'unavailable' errors
00470             if not is_unavailable_exception(e):
00471                 # protocol error; provide additional information in test output
00472                 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))

Here is the call graph for this function:

Definition at line 450 of file test_xmlrpc.py.

00450 
00451     def test_simple1(self):
00452         try:
00453             p = xmlrpclib.ServerProxy(URL)
00454             self.assertEqual(p.pow(6,8), 6**8)
00455         except (xmlrpclib.ProtocolError, socket.error) as e:
00456             # ignore failures due to non-blocking socket 'unavailable' errors
00457             if not is_unavailable_exception(e):
00458                 # protocol error; provide additional information in test output
00459                 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 474 of file test_xmlrpc.py.

00474 
00475     def XXXtest_404(self):
00476         # send POST with http.client, it should return 404 header and
00477         # 'Not Found' message.
00478         conn = httplib.client.HTTPConnection(ADDR, PORT)
00479         conn.request('POST', '/this-is-not-valid')
00480         response = conn.getresponse()
00481         conn.close()
00482 
00483         self.assertEqual(response.status, 404)
00484         self.assertEqual(response.reason, 'Not Found')

Here is the call graph for this function:


Member Data Documentation

Definition at line 428 of file test_xmlrpc.py.

Definition at line 420 of file test_xmlrpc.py.

Reimplemented in test.test_xmlrpc.MultiPathServerTestCase.

Definition at line 422 of file test_xmlrpc.py.


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