1.1 --- a/tests/soap_test.py Sun Sep 30 23:23:40 2007 +0000
1.2 +++ b/tests/soap_test.py Sun Sep 30 23:23:48 2007 +0000
1.3 @@ -30,6 +30,15 @@
1.4 </env:Envelope>"""
1.5
1.6 req = libxml2dom.soap.parseString(request)
1.7 +assert req.methodName == "chargeReservation"
1.8 +assert req.parameterValues == [
1.9 + [("code", "FT35ZBQ")],
1.10 + [("name", u"Åke Jógvan Øyvind"), ("number", "123456789099999"), ("expiration", "2005-02")]
1.11 + ]
1.12 +assert req.fault is None
1.13 +print "Method name:", req.methodName
1.14 +print "Parameter values:", req.parameterValues
1.15 +print "Fault:", req.fault
1.16
1.17 response = """<?xml version='1.0' encoding='iso-8859-1'?>
1.18 <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" >
1.19 @@ -52,6 +61,12 @@
1.20 </env:Envelope>"""
1.21
1.22 resp = libxml2dom.soap.parseString(response)
1.23 +assert resp.methodName == "chargeReservationResponse"
1.24 +assert resp.parameterValues == [("code", "FT35ZBQ"), ("viewAt", "http://travelcompany.example.org/reservations?code=FT35ZBQ")]
1.25 +assert resp.fault is None
1.26 +print "Method name:", resp.methodName
1.27 +print "Parameter values:", resp.parameterValues
1.28 +print "Fault:", resp.fault
1.29
1.30 response2 = """<?xml version='1.0' encoding='iso-8859-1'?>
1.31 <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" >
1.32 @@ -77,6 +92,15 @@
1.33 </env:Envelope>"""
1.34
1.35 resp2 = libxml2dom.soap.parseString(response2)
1.36 +assert resp2.methodName == "chargeReservationResponse"
1.37 +assert resp2.parameterValues == [
1.38 + ("result", "m:status"), ("status", "confirmed"), ("code", "FT35ZBQ"),
1.39 + ("viewAt", "http://travelcompany.example.org/reservations?code=FT35ZBQ")
1.40 + ]
1.41 +assert resp2.fault is None
1.42 +print "Method name:", resp2.methodName
1.43 +print "Parameter values:", resp2.parameterValues
1.44 +print "Fault:", resp2.fault
1.45
1.46 failed = """<?xml version='1.0' encoding='iso-8859-1'?>
1.47 <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
1.48 @@ -105,5 +129,12 @@
1.49 </env:Envelope>"""
1.50
1.51 f = libxml2dom.soap.parseString(failed)
1.52 +assert f.methodName is None
1.53 +assert f.parameterValues == []
1.54 +assert f.fault.code == "env:Sender"
1.55 +assert f.fault.subcode == "rpc:BadArguments"
1.56 +print "Method name:", f.methodName
1.57 +print "Parameter values:", f.parameterValues
1.58 +print "Fault code:", f.fault.code
1.59
1.60 # vim: tabstop=4 expandtab shiftwidth=4