Best Python code snippet using slash
test_xmlrpc.py
Source:test_xmlrpc.py
...83 return_datetime.exposed = True84 def return_boolean(self):85 return True86 return_boolean.exposed = True87 def test_argument_passing(self, num):88 return num * 289 test_argument_passing.exposed = True90 def test_returning_Fault(self):91 return Fault(1, "custom Fault response")92 test_returning_Fault.exposed = True93 root = Root()94 root.xmlrpc = XmlRpc()95 cherrypy.tree.mount(root, config={'/': {96 'request.dispatch': cherrypy.dispatch.XMLRPCDispatcher(),97 'tools.xmlrpc.allow_none': 0,98 }})99from cherrypy.test import helper100class XmlRpcTest(helper.CPWebCase):101 setup_server = staticmethod(setup_server)102 def testXmlRpc(self):103 104 scheme = self.scheme105 if scheme == "https":106 url = 'https://%s:%s/xmlrpc/' % (self.interface(), self.PORT)107 proxy = ServerProxy(url, transport=HTTPSTransport())108 else:109 url = 'http://%s:%s/xmlrpc/' % (self.interface(), self.PORT)110 proxy = ServerProxy(url)111 112 # begin the tests ...113 self.getPage("/xmlrpc/foo")114 self.assertBody("Hello world!")115 116 self.assertEqual(proxy.return_single_item_list(), [42])117 self.assertNotEqual(proxy.return_single_item_list(), 'one bazillion')118 self.assertEqual(proxy.return_string(), "here is a string")119 self.assertEqual(proxy.return_tuple(), list(('here', 'is', 1, 'tuple')))120 self.assertEqual(proxy.return_dict(), {'a': 1, 'c': 3, 'b': 2})121 self.assertEqual(proxy.return_composite(),122 [{'a': 1, 'z': 26}, 'hi', ['welcome', 'friend']])123 self.assertEqual(proxy.return_int(), 42)124 self.assertEqual(proxy.return_float(), 3.14)125 self.assertEqual(proxy.return_datetime(),126 DateTime((2003, 10, 7, 8, 1, 0, 1, 280, -1)))127 self.assertEqual(proxy.return_boolean(), True)128 self.assertEqual(proxy.test_argument_passing(22), 22 * 2)129 130 # Test an error in the page handler (should raise an xmlrpclib.Fault)131 try:132 proxy.test_argument_passing({})133 except Exception:134 x = sys.exc_info()[1]135 self.assertEqual(x.__class__, Fault)136 self.assertEqual(x.faultString, ("unsupported operand type(s) "137 "for *: 'dict' and 'int'"))138 else:139 self.fail("Expected xmlrpclib.Fault")140 141 # http://www.cherrypy.org/ticket/533142 # if a method is not found, an xmlrpclib.Fault should be raised143 try:144 proxy.non_method()145 except Exception:146 x = sys.exc_info()[1]...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!