# HG changeset patch
# User paulb
# Date 1191699227 0
# Node ID 832e661001e161be9cc6e8acd8ce8be83f749a1d
# Parent 1872e9e7e1b13e884dacaaeb3b0af429b87c59fb
[project @ 2007-10-06 19:33:47 by paulb]
Introduced a ParameterName class in order to attempt to encapsulate naming
differences between XML-RPC and SOAP.
Added XML-RPC array support.
Renamed parameterValues property to rawParameterValues, with a new
parameterValues property performing conversion on the retrieved values.
diff -r 1872e9e7e1b1 -r 832e661001e1 tests/soap_test.py
--- a/tests/soap_test.py Sat Oct 06 19:33:22 2007 +0000
+++ b/tests/soap_test.py Sat Oct 06 19:33:47 2007 +0000
@@ -31,19 +31,19 @@
req = libxml2dom.soap.parseString(request)
assert req.method.methodName == "chargeReservation"
-assert req.method.parameterValues == [
- (("http://travelcompany.example.org/reservation", "m:reservation"), [
- (("http://travelcompany.example.org/reservation", "m:code"), "FT35ZBQ")
+assert req.method.rawParameterValues == [
+ (("http://travelcompany.example.org/reservation", "reservation"), [
+ (("http://travelcompany.example.org/reservation", "code"), "FT35ZBQ")
]),
- (("http://mycompany.example.com/financial", "o:creditCard"), [
- (("http://mycompany.example.com/employees", "n:name"), u"Åke Jógvan Øyvind"),
- (("http://mycompany.example.com/financial", "o:number"), "123456789099999"),
- (("http://mycompany.example.com/financial", "o:expiration"), "2005-02")
+ (("http://mycompany.example.com/financial", "creditCard"), [
+ (("http://mycompany.example.com/employees", "name"), u"Åke Jógvan Øyvind"),
+ (("http://mycompany.example.com/financial", "number"), "123456789099999"),
+ (("http://mycompany.example.com/financial", "expiration"), "2005-02")
])
]
assert req.fault is None
print "Method name:", req.method.methodName
-print "Parameter values:", req.method.parameterValues
+print "Parameter values:", req.method.rawParameterValues
print "Fault:", req.fault
response = """
@@ -68,13 +68,13 @@
resp = libxml2dom.soap.parseString(response)
assert resp.method.methodName == "chargeReservationResponse"
-assert resp.method.parameterValues == [
- (("http://travelcompany.example.org/", "m:code"), "FT35ZBQ"),
- (("http://travelcompany.example.org/", "m:viewAt"), "http://travelcompany.example.org/reservations?code=FT35ZBQ")
+assert resp.method.rawParameterValues == [
+ (("http://travelcompany.example.org/", "code"), "FT35ZBQ"),
+ (("http://travelcompany.example.org/", "viewAt"), "http://travelcompany.example.org/reservations?code=FT35ZBQ")
]
assert resp.fault is None
print "Method name:", resp.method.methodName
-print "Parameter values:", resp.method.parameterValues
+print "Parameter values:", resp.method.rawParameterValues
print "Fault:", resp.fault
response2 = """
@@ -102,15 +102,15 @@
resp2 = libxml2dom.soap.parseString(response2)
assert resp2.method.methodName == "chargeReservationResponse"
-assert resp2.method.parameterValues == [
- (("http://www.w3.org/2003/05/soap-rpc", "rpc:result"), "m:status"),
- (("http://travelcompany.example.org/", "m:status"), "confirmed"),
- (("http://travelcompany.example.org/", "m:code"), "FT35ZBQ"),
- (("http://travelcompany.example.org/", "m:viewAt"), "http://travelcompany.example.org/reservations?code=FT35ZBQ")
+assert resp2.method.rawParameterValues == [
+ (("http://www.w3.org/2003/05/soap-rpc", "result"), "m:status"),
+ (("http://travelcompany.example.org/", "status"), "confirmed"),
+ (("http://travelcompany.example.org/", "code"), "FT35ZBQ"),
+ (("http://travelcompany.example.org/", "viewAt"), "http://travelcompany.example.org/reservations?code=FT35ZBQ")
]
assert resp2.fault is None
print "Method name:", resp2.method.methodName
-print "Parameter values:", resp2.method.parameterValues
+print "Parameter values:", resp2.method.rawParameterValues
print "Fault:", resp2.fault
failed = """
diff -r 1872e9e7e1b1 -r 832e661001e1 tests/xmlrpc_test.py
--- a/tests/xmlrpc_test.py Sat Oct 06 19:33:22 2007 +0000
+++ b/tests/xmlrpc_test.py Sat Oct 06 19:33:47 2007 +0000
@@ -16,10 +16,10 @@
req = libxml2dom.xmlrpc.parseString(request)
assert req.method.methodName == "examples.getStateName"
-assert req.method.parameterValues == [("i4", "41")]
+assert req.method.rawParameterValues == [(("i4", ""), "41")]
assert req.fault is None
print "Method name:", req.method.methodName
-print "Parameter values:", req.method.parameterValues
+print "Parameter values:", req.method.rawParameterValues
print "Fault:", req.fault
response = """
@@ -33,10 +33,10 @@
resp = libxml2dom.xmlrpc.parseString(response)
assert resp.method.methodName is None
-assert resp.method.parameterValues == [("string", "South Dakota")]
+assert resp.method.rawParameterValues == [(("string", ""), "South Dakota")]
assert resp.fault is None
print "Method name:", resp.method.methodName
-print "Parameter values:", resp.method.parameterValues
+print "Parameter values:", resp.method.rawParameterValues
print "Fault:", resp.fault
failed = """
@@ -59,11 +59,11 @@
f = libxml2dom.xmlrpc.parseString(failed)
assert f.method.methodName is None
-assert f.method.parameterValues == []
+assert f.method.rawParameterValues == []
assert f.fault.code == "4"
assert f.fault.reason == "Too many parameters."
print "Method name:", f.method.methodName
-print "Parameter values:", f.method.parameterValues
+print "Parameter values:", f.method.rawParameterValues
print "Fault code:", f.fault.code
# Python Package Index examples.
@@ -96,10 +96,93 @@
s = libxml2dom.xmlrpc.parseString(search)
assert s.method.methodName == "search"
-assert s.method.parameterValues == [("struct", [("name", ("string", "libxml2dom")), ("description", ("string", "XML"))]), ("string", "and")]
+assert s.method.rawParameterValues == [
+ (("struct", None), [
+ (("string", "name"), "libxml2dom"), (("string", "description"), "XML")
+ ]),
+ (("string", None), "and")
+ ]
assert s.fault is None
print "Method name:", s.method.methodName
-print "Parameter values:", s.method.parameterValues
+print "Parameter values:", s.method.rawParameterValues
print "Fault:", s.fault
+# Nested structure examples.
+
+search2 = """
+
+ search
+
+
+
+
+
+ names
+
+
+
+ name
+ libxml2dom
+
+
+ description
+ XML
+
+
+
+
+
+
+
+
+
+ and
+
+
+
+"""
+
+s2 = libxml2dom.xmlrpc.parseString(search2)
+assert s2.method.methodName == "search"
+assert s2.method.rawParameterValues == [
+ (("struct", None), [
+ (("struct", "names"), [(("string", "name"), "libxml2dom"), (("string", "description"), "XML")])
+ ]),
+ (("string", None), "and")
+ ]
+assert s2.fault is None
+print "Method name:", s2.method.methodName
+print "Parameter values:", s2.method.rawParameterValues
+print "Fault:", s2.fault
+
+arrays = """
+
+
+
+
+
+
+
+ libxml2dom
+
+
+ XSLTools
+
+
+
+
+
+
+ """
+
+a = libxml2dom.xmlrpc.parseString(arrays)
+assert a.method.methodName is None
+assert a.method.rawParameterValues == [
+ (("array", None), [(("string", None), "libxml2dom"), (("string", None), "XSLTools")])
+ ]
+assert a.fault is None
+print "Method name:", a.method.methodName
+print "Parameter values:", a.method.rawParameterValues
+print "Fault:", a.fault
+
# vim: tabstop=4 expandtab shiftwidth=4