make unsupported external tests closer to using shared Python 2/3 code
No longer ignoring KeyboardInterrupt & SystemExit exceptions in some places when running under Python 2.4.x. Minor stylistic changes.
This commit is contained in:
parent
a3866610cc
commit
17033a6b91
|
@ -14,20 +14,20 @@
|
|||
# written by: Jeff Ortel ( jortel@redhat.com )
|
||||
|
||||
#
|
||||
# This test requires installation or visibility to my local axis(1) server.
|
||||
# This test requires installation or visibility of my local axis(1) server.
|
||||
#
|
||||
|
||||
import sys
|
||||
sys.path.append('../../')
|
||||
|
||||
import traceback as tb
|
||||
from tests import *
|
||||
from suds import WebFault
|
||||
from suds.client import Client
|
||||
from suds.sudsobject import Object
|
||||
from suds.transport.https import HttpAuthenticated
|
||||
from suds.plugin import *
|
||||
|
||||
import traceback as tb
|
||||
|
||||
|
||||
errors = 0
|
||||
credentials = dict(username='jortel', password='abc123')
|
||||
|
@ -36,34 +36,34 @@ credentials = dict(username='jortel', password='abc123')
|
|||
class MyInitPlugin(InitPlugin):
|
||||
|
||||
def initialized(self, context):
|
||||
print 'PLUGIN (init): initialized: ctx=%s' % context.__dict__
|
||||
print('PLUGIN (init): initialized: ctx=%s' % (context.__dict__,))
|
||||
|
||||
|
||||
class MyDocumentPlugin(DocumentPlugin):
|
||||
|
||||
def loaded(self, context):
|
||||
print 'PLUGIN (document): loaded: ctx=%s' % context.__dict__
|
||||
print('PLUGIN (document): loaded: ctx=%s' % (context.__dict__,))
|
||||
|
||||
def parsed(self, context):
|
||||
print 'PLUGIN (document): parsed: ctx=%s' % context.__dict__
|
||||
print('PLUGIN (document): parsed: ctx=%s' % (context.__dict__,))
|
||||
|
||||
|
||||
class MyMessagePlugin(MessagePlugin):
|
||||
|
||||
def marshalled(self, context):
|
||||
print 'PLUGIN (message): marshalled: ctx=%s' % context.__dict__
|
||||
print('PLUGIN (message): marshalled: ctx=%s' % (context.__dict__,))
|
||||
|
||||
def sending(self, context):
|
||||
print 'PLUGIN (message): sending: ctx=%s' % context.__dict__
|
||||
print('PLUGIN (message): sending: ctx=%s' % (context.__dict__,))
|
||||
|
||||
def received(self, context):
|
||||
print 'PLUGIN (message): received: ctx=%s' % context.__dict__
|
||||
print('PLUGIN (message): received: ctx=%s' % (context.__dict__,))
|
||||
|
||||
def parsed(self, context):
|
||||
print 'PLUGIN (message): parsed: ctx=%s' % context.__dict__
|
||||
print('PLUGIN (message): parsed: ctx=%s' % (context.__dict__,))
|
||||
|
||||
def unmarshalled(self, context):
|
||||
print 'PLUGIN: (massage): unmarshalled: ctx=%s' % context.__dict__
|
||||
print('PLUGIN: (massage): unmarshalled: ctx=%s' % (context.__dict__,))
|
||||
|
||||
|
||||
myplugins = (
|
||||
|
@ -75,27 +75,27 @@ myplugins = (
|
|||
|
||||
def start(url):
|
||||
global errors
|
||||
print '\n________________________________________________________________\n'
|
||||
print 'Test @ ( %s )\nerrors = %d\n' % (url, errors)
|
||||
print('\n______________________________________________________________\n')
|
||||
print('Test @ ( %s )\nerrors = %d\n' % (url, errors))
|
||||
|
||||
try:
|
||||
url = 'http://localhost:8081/axis/services/basic-rpc-encoded?wsdl'
|
||||
start(url)
|
||||
t = HttpAuthenticated(**credentials)
|
||||
client = Client(url, transport=t, cache=None, plugins=myplugins)
|
||||
print client
|
||||
print(client)
|
||||
#
|
||||
# create a name object using the wsdl
|
||||
#
|
||||
print 'create name'
|
||||
print('create name')
|
||||
name = client.factory.create('ns0:Name')
|
||||
name.first = u'jeff'+unichr(1234)
|
||||
name.last = 'ortel'
|
||||
print name
|
||||
print(name)
|
||||
#
|
||||
# create a phone object using the wsdl
|
||||
#
|
||||
print 'create phone'
|
||||
print('create phone')
|
||||
phoneA = client.factory.create('ns0:Phone')
|
||||
phoneA.npa = 410
|
||||
phoneA.nxx = 555
|
||||
|
@ -119,18 +119,18 @@ try:
|
|||
# create a person object using the wsdl
|
||||
#
|
||||
person = client.factory.create('ns0:Person')
|
||||
print '{empty} person=\n%s' % person
|
||||
print('{empty} person=\n%s' % (person,))
|
||||
person.name = name
|
||||
person.age = 43
|
||||
person.phone = [phoneA,phoneB,phoneC]
|
||||
person.pets = [dog]
|
||||
print 'person=\n%s' % person
|
||||
print('person=\n%s' % (person,))
|
||||
#
|
||||
# add the person (using the webservice)
|
||||
#
|
||||
print 'addPersion()'
|
||||
print('addPersion()')
|
||||
result = client.service.addPerson(person)
|
||||
print '\nreply(\n%s\n)\n' % str(result)
|
||||
print('\nreply(\n%s\n)\n' % (str(result),))
|
||||
|
||||
#
|
||||
# Async
|
||||
|
@ -159,22 +159,24 @@ try:
|
|||
ap.age = person.age
|
||||
ap.phone = person.phone
|
||||
ap.pets = person.pets
|
||||
print 'AnotherPerson\n%s' % ap
|
||||
print('AnotherPerson\n%s' % (ap,))
|
||||
#
|
||||
# update the person's name (using the webservice)
|
||||
#
|
||||
print 'updatePersion()'
|
||||
print('updatePersion()')
|
||||
result = client.service.updatePerson(ap, newname)
|
||||
print '\nreply(\n%s\n)\n' % str(result)
|
||||
print('\nreply(\n%s\n)\n' % (str(result),))
|
||||
result = client.service.updatePerson(ap, None)
|
||||
print '\nreply(\n%s\n)\n' % str(result)
|
||||
print('\nreply(\n%s\n)\n' % (str(result),))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
|
@ -182,19 +184,19 @@ try:
|
|||
start(url)
|
||||
t = HttpAuthenticated(**credentials)
|
||||
client = Client(url, transport=t, cache=None)
|
||||
print client
|
||||
print(client)
|
||||
#
|
||||
# create a name object as dict
|
||||
#
|
||||
print 'create name'
|
||||
print('create name')
|
||||
name = {}
|
||||
name['first'] = 'Elmer'
|
||||
name['last'] = 'Fudd'
|
||||
print name
|
||||
print(name)
|
||||
#
|
||||
# create a phone as dict
|
||||
#
|
||||
print 'create phone'
|
||||
print('create phone')
|
||||
phoneA = {}
|
||||
phoneA['npa'] = 410
|
||||
phoneA['nxx'] = 555
|
||||
|
@ -219,133 +221,149 @@ try:
|
|||
# create a person as dict
|
||||
#
|
||||
person = {}
|
||||
print '{empty} person=\n%s' % person
|
||||
print('{empty} person=\n%s' % (person,))
|
||||
person['name'] = name
|
||||
person['age'] = 43
|
||||
person['phone'] = [phoneA,phoneB, phoneC]
|
||||
person['phone'] = [phoneA, phoneB, phoneC]
|
||||
person['pets'] = [dog]
|
||||
print 'person=\n%s' % person
|
||||
print('person=\n%s' % (person,))
|
||||
#
|
||||
# add the person (using the webservice)
|
||||
#
|
||||
print 'addPersion()'
|
||||
print('addPersion()')
|
||||
result = client.service.addPerson(person)
|
||||
print '\nreply(\n%s\n)\n' % str(result)
|
||||
print('\nreply(\n%s\n)\n' % (str(result),))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
print "echo(' this is cool ')"
|
||||
print("echo(' this is cool ')")
|
||||
result = client.service.echo('this is cool')
|
||||
print '\nreply( "%s" )\n' % str(result)
|
||||
print 'echo(None)'
|
||||
print('\nreply( "%s" )\n' % (str(result),))
|
||||
print('echo(None)')
|
||||
result = client.service.echo(None)
|
||||
print '\nreply( "%s" )\n' % str(result)
|
||||
print('\nreply( "%s" )\n' % (str(result),))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
print 'hello()'
|
||||
print('hello()')
|
||||
result = client.service.hello()
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
print 'testVoid()'
|
||||
print('testVoid()')
|
||||
result = client.service.getVoid()
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
print '** new style arrays **'
|
||||
print('** new style arrays **')
|
||||
words = ['my', 'dog', 'likes', 'steak']
|
||||
result = client.service.printList(words)
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
|
||||
print '** old style arrays **'
|
||||
print('** old style arrays **')
|
||||
array = client.factory.create('ArrayOf_xsd_string')
|
||||
print 'ArrayOf_xsd_string=\n%s' % array
|
||||
print('ArrayOf_xsd_string=\n%s' % (array,))
|
||||
array.item = ['my', 'dog', 'likes', 'steak']
|
||||
result = client.service.printList(array)
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
s = 'hello'
|
||||
for n in range(0, 3):
|
||||
print 'getList(%s, %d)' % (s, n)
|
||||
print('getList(%s, %d)' % (s, n))
|
||||
result = client.service.getList(s, n)
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
assert ( isinstance(result, list) and len(result) == n )
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
print 'testExceptions()'
|
||||
print('testExceptions()')
|
||||
result = client.service.throwException()
|
||||
print '\nreply( %s )\n' % tostr(result)
|
||||
print('\nreply( %s )\n' % (tostr(result),))
|
||||
raise Exception('Fault expected and not raised')
|
||||
except WebFault, f:
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
url = 'http://localhost:8081/axis/services/basic-rpc-encoded?wsdl'
|
||||
start(url)
|
||||
client = Client(url, faults=False, **credentials)
|
||||
print 'testExceptions()'
|
||||
print('testExceptions()')
|
||||
result = client.service.throwException()
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
print '\nFinished: errors=%d' % errors
|
||||
print('\nFinished: errors=%d' % (errors,))
|
||||
|
|
|
@ -16,15 +16,15 @@
|
|||
import sys
|
||||
sys.path.append('../../')
|
||||
|
||||
from tests import *
|
||||
from suds import *
|
||||
from suds.client import Client
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
errors = 0
|
||||
url = 'http://localhost:8080/axis2/services/BasicService?wsdl'
|
||||
print 'url=%s' % url
|
||||
print('url=%s' % (url,))
|
||||
|
||||
#
|
||||
# create a service client using the wsdl.
|
||||
|
@ -34,25 +34,25 @@ client = Client(url)
|
|||
#
|
||||
# print the service (introspection)
|
||||
#
|
||||
print client
|
||||
print(client)
|
||||
|
||||
print 'printList()'
|
||||
print client.service.printList(['a','b'])
|
||||
print('printList()')
|
||||
print(client.service.printList(['a', 'b']))
|
||||
|
||||
#
|
||||
# create a name object using the wsdl
|
||||
#
|
||||
print 'create name'
|
||||
print('create name')
|
||||
name = client.factory.create('ns2:Name')
|
||||
name.first = u'jeff'+unichr(1234)
|
||||
name.last = 'ortel'
|
||||
|
||||
print name
|
||||
print(name)
|
||||
|
||||
#
|
||||
# create a phone object using the wsdl
|
||||
#
|
||||
print 'create phone'
|
||||
print('create phone')
|
||||
phoneA = client.factory.create('ns2:Phone')
|
||||
phoneA.npa = 410
|
||||
phoneA.nxx = 822
|
||||
|
@ -67,10 +67,10 @@ phoneB.number = 4406
|
|||
# create a dog
|
||||
#
|
||||
dog = client.factory.create('ns2:Dog')
|
||||
print dog
|
||||
print(dog)
|
||||
dog.name = 'Chance'
|
||||
dog.trained = True
|
||||
print dog
|
||||
print(dog)
|
||||
|
||||
#
|
||||
# create a person object using the wsdl
|
||||
|
@ -80,7 +80,7 @@ person = client.factory.create('ns2:Person')
|
|||
#
|
||||
# inspect empty person
|
||||
#
|
||||
print '{empty} person=\n%s' % person
|
||||
print('{empty} person=\n%s' % (person,))
|
||||
|
||||
person.name = name
|
||||
person.age = None
|
||||
|
@ -92,14 +92,14 @@ person.pets.append(dog)
|
|||
#
|
||||
# inspect person
|
||||
#
|
||||
print 'person=\n%s' % person
|
||||
print('person=\n%s' % (person,))
|
||||
|
||||
#
|
||||
# add the person (using the webservice)
|
||||
#
|
||||
print 'addPersion()'
|
||||
print('addPersion()')
|
||||
result = client.service.addPerson(person)
|
||||
print '\nreply(\n%s\n)\n' % result.encode('utf-8')
|
||||
print('\nreply(\n%s\n)\n' % (result.encode('utf-8'),))
|
||||
|
||||
#
|
||||
# create a new name object used to update the person
|
||||
|
@ -111,96 +111,104 @@ newname.last = None
|
|||
#
|
||||
# update the person's name (using the webservice) and print return person object
|
||||
#
|
||||
print 'updatePersion()'
|
||||
print('updatePersion()')
|
||||
result = client.service.updatePerson(person, newname)
|
||||
print '\nreply(\n%s\n)\n' % str(result)
|
||||
print('\nreply(\n%s\n)\n' % (str(result),))
|
||||
result = client.service.updatePerson(person, None)
|
||||
print '\nreply(\n%s\n)\n' % str(result)
|
||||
print('\nreply(\n%s\n)\n' % (str(result),))
|
||||
|
||||
|
||||
#
|
||||
# invoke the echo service
|
||||
#
|
||||
print 'echo()'
|
||||
print('echo()')
|
||||
client.service.echo(None)
|
||||
result = client.service.echo('this is cool')
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
|
||||
print 'echo() with {none}'
|
||||
print('echo() with {none}')
|
||||
result = client.service.echo(None)
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
|
||||
#
|
||||
# invoke the hello service
|
||||
#
|
||||
print 'hello()'
|
||||
print('hello()')
|
||||
result = client.service.hello()
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
|
||||
#
|
||||
# invoke the testVoid service
|
||||
#
|
||||
try:
|
||||
print 'getVoid()'
|
||||
print('getVoid()')
|
||||
result = client.service.getVoid()
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
except Exception, e:
|
||||
print e
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
print(sys.exc_info()[1])
|
||||
|
||||
#
|
||||
# test list args
|
||||
#
|
||||
print 'getList(list)'
|
||||
print('getList(list)')
|
||||
mylist = ['my', 'dog', 'likes', 'steak']
|
||||
result = client.service.printList(mylist)
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
# tuple
|
||||
print 'testListArgs(tuple)'
|
||||
print('testListArgs(tuple)')
|
||||
mylist = ('my', 'dog', 'likes', 'steak')
|
||||
result = client.service.printList(mylist)
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
|
||||
#
|
||||
# test list returned
|
||||
#
|
||||
for n in range(0, 3):
|
||||
print 'getList(str, %d)' % n
|
||||
print('getList(str, %d)' % (n,))
|
||||
result = client.service.getList('hello', n)
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
assert ( isinstance(result, list) and len(result) == n )
|
||||
|
||||
print 'addPet()'
|
||||
print('addPet()')
|
||||
dog = client.factory.create('ns2:Dog')
|
||||
dog.name = 'Chance'
|
||||
dog.trained = True
|
||||
print dog
|
||||
print(dog)
|
||||
try:
|
||||
result = client.service.addPet(person, dog)
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
except Exception, e:
|
||||
print e
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
print(sys.exc_info()[1])
|
||||
|
||||
print '___________________ E X C E P T I O N S __________________________'
|
||||
print('___________________ E X C E P T I O N S __________________________')
|
||||
|
||||
#
|
||||
# test exceptions
|
||||
#
|
||||
try:
|
||||
print 'throwException() faults=True'
|
||||
print('throwException() faults=True')
|
||||
result = client.service.throwException()
|
||||
print '\nreply( %s )\n' % tostr(result)
|
||||
except Exception, e:
|
||||
print e
|
||||
print('\nreply( %s )\n' % (tostr(result),))
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
print(sys.exc_info()[1])
|
||||
|
||||
#
|
||||
# test faults
|
||||
#
|
||||
try:
|
||||
print 'throwException() faults=False'
|
||||
print('throwException() faults=False')
|
||||
client.set_options(faults=False)
|
||||
result = client.service.throwException()
|
||||
print '\nreply( %s )\n' % tostr(result)
|
||||
except Exception, e:
|
||||
print e
|
||||
print('\nreply( %s )\n' % (tostr(result),))
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
print(sys.exc_info()[1])
|
||||
|
||||
print '\nfinished: errors=%d' % errors
|
||||
print('\nfinished: errors=%d' % (errors,))
|
||||
|
|
|
@ -16,32 +16,34 @@
|
|||
import sys
|
||||
sys.path.append('../../')
|
||||
|
||||
import traceback as tb
|
||||
from tests import *
|
||||
from suds import WebFault
|
||||
from suds.client import Client
|
||||
|
||||
import traceback as tb
|
||||
|
||||
|
||||
errors = 0
|
||||
|
||||
|
||||
def start(url):
|
||||
print '\n________________________________________________________________\n'
|
||||
print 'Test @ ( %s )' % url
|
||||
print('\n______________________________________________________________\n')
|
||||
print('Test @ ( %s )' % (url,))
|
||||
|
||||
try:
|
||||
url = 'http://localhost:9090/jasperserver-pro/services/repository?wsdl'
|
||||
start(url)
|
||||
client = Client(url, username='jeff', password='ortel')
|
||||
print client
|
||||
print client.service.list('')
|
||||
print(client)
|
||||
print(client.service.list(''))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
print '\nFinished: errors = %d' % errors
|
||||
print('\nFinished: errors = %d' % (errors,))
|
||||
|
|
|
@ -18,7 +18,6 @@ sys.path.append('../../')
|
|||
|
||||
import traceback as tb
|
||||
import suds.metrics as metrics
|
||||
from tests import *
|
||||
from suds import WebFault
|
||||
from suds.client import Client
|
||||
|
||||
|
@ -28,231 +27,255 @@ errors = 0
|
|||
|
||||
def start(url):
|
||||
global errors
|
||||
print '\n________________________________________________________________\n'
|
||||
print 'Test @ ( %s ) %d' % (url, errors)
|
||||
print('\n______________________________________________________________\n')
|
||||
print('Test @ ( %s ) %d' % (url, errors))
|
||||
|
||||
try:
|
||||
url = 'http://mssoapinterop.org/asmx/simple.asmx?WSDL'
|
||||
start(url)
|
||||
client = Client(url)
|
||||
print client
|
||||
print(client)
|
||||
# string
|
||||
input = "42"
|
||||
d = dict(inputString=input)
|
||||
result = client.service.echoString(**d)
|
||||
print 'echoString() = %s' % result
|
||||
print('echoString() = %s' % (result,))
|
||||
assert result == input
|
||||
# int
|
||||
input = 42
|
||||
result = client.service.echoInteger(input)
|
||||
print 'echoInteger() = %s' % result
|
||||
print('echoInteger() = %s' % (result,))
|
||||
assert result == input
|
||||
# float
|
||||
input = 4.2
|
||||
result = client.service.echoFloat(input)
|
||||
print 'echoFloat() = %s' % result
|
||||
print('echoFloat() = %s' % (result,))
|
||||
assert result == input
|
||||
# suds 0.3.8+
|
||||
result = client.service.echoIntegerArray([])
|
||||
print 'echoIntegerArray() = %s' % result
|
||||
print('echoIntegerArray() = %s' % (result,))
|
||||
assert result is None
|
||||
input = [1,2,3,4]
|
||||
input = [1, 2, 3, 4]
|
||||
result = client.service.echoIntegerArray(input)
|
||||
print 'echoIntegerArray() = %s' % result
|
||||
print('echoIntegerArray() = %s' % (result,))
|
||||
assert result == input
|
||||
result = client.service.echoIntegerArray(inputIntegerArray=input)
|
||||
print 'echoIntegerArray() = %s' % result
|
||||
print('echoIntegerArray() = %s' % (result,))
|
||||
assert result == input
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
url = 'http://jira.atlassian.com/rpc/soap/jirasoapservice-v2?wsdl'
|
||||
start(url)
|
||||
client = Client(url)
|
||||
print client
|
||||
print(client)
|
||||
token = client.service.login('soaptester', 'soaptester')
|
||||
print 'token="%s"' % token
|
||||
print('token="%s"' % (token,))
|
||||
user = client.service.getUser(token, 'soaptester')
|
||||
print 'user="%s"' % user
|
||||
print('user="%s"' % (user,))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
url = 'http://jira.atlassian.com/rpc/soap/jirasoapservice-v2?wsdl'
|
||||
start(url+' ** cloned **')
|
||||
client = Client(url).clone()
|
||||
print '**clone**\n%s' % client
|
||||
print('**clone**\n%s' % (client,))
|
||||
token = client.service.login('soaptester', 'soaptester')
|
||||
print '**clone** token="%s"' % token
|
||||
print('**clone** token="%s"' % (token,))
|
||||
user = client.service.getUser(token, 'soaptester')
|
||||
print '**clone** user="%s"' % user
|
||||
print('**clone** user="%s"' % (user,))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
url = ' http://www.boyzoid.com/comp/randomQuote.cfc?wsdl '
|
||||
start(url)
|
||||
client = Client(url)
|
||||
print client
|
||||
print client.service.getQuote(False)
|
||||
print(client)
|
||||
print(client.service.getQuote(False))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
url = 'http://www.zenfolio.com/zf/api/zfapi.asmx?wsdl'
|
||||
start(url)
|
||||
client = Client(url)
|
||||
print client
|
||||
print(client)
|
||||
#client.setport(0)
|
||||
group = client.factory.create('Group')
|
||||
print 'Group:\n%s' % group
|
||||
print 'LoadGroupHierarchy("demo")'
|
||||
print('Group:\n%s' % (group,))
|
||||
print('LoadGroupHierarchy("demo")')
|
||||
groupHierarchy = client.service.LoadGroupHierarchy("demo")
|
||||
print 'result:\n%s' % groupHierarchy
|
||||
print('result:\n%s' % (groupHierarchy,))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
url = 'http://cert.synxis.com/interface/ChannelConnect.asmx?WSDL'
|
||||
start(url)
|
||||
client = Client(url)
|
||||
print client
|
||||
print(client)
|
||||
#client.setport(0)
|
||||
tpa = client.factory.create('ns1:TPA_Extensions')
|
||||
print client.service.Ping(tpa, "hello")
|
||||
print(client.service.Ping(tpa, "hello"))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
url = 'https://sec.neurofuzz-software.com/paos/genSSHA-SOAP.php?wsdl'
|
||||
start(url)
|
||||
client = Client(url)
|
||||
print client
|
||||
print client.service.genSSHA('hello', 'sha1')
|
||||
print(client)
|
||||
print(client.service.genSSHA('hello', 'sha1'))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
url = 'http://ap1314-dsr.compmed.ucdavis.edu/dataserver/Aperio.Images/Image?method=wsdl'
|
||||
start(url)
|
||||
client = Client(url)
|
||||
#print client.factory.resolver.schema
|
||||
print client
|
||||
print 'Logon()'
|
||||
reply = client.service.Logon('testuser','test')
|
||||
print reply
|
||||
#print(client.factory.resolver.schema)
|
||||
print(client)
|
||||
print('Logon()')
|
||||
reply = client.service.Logon('testuser', 'test')
|
||||
print(reply)
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
url = 'http://soa.ebrev.info/service.wsdl'
|
||||
start(url)
|
||||
client = Client(url)
|
||||
print client
|
||||
print(client)
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
url = 'http://arcweb.esri.com/services/v2/MapImage.wsdl'
|
||||
start(url)
|
||||
client = Client(url)
|
||||
print client
|
||||
print(client)
|
||||
env = client.factory.create('ns2:Envelope')
|
||||
print env
|
||||
print(env)
|
||||
options = client.factory.create('ns4:MapImageOptions')
|
||||
print options
|
||||
print(options)
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
url = "http://www.thomas-bayer.com/axis2/services/BLZService?wsdl"
|
||||
start(url)
|
||||
client = Client(url)
|
||||
print client
|
||||
print(client)
|
||||
#client.setport(0)
|
||||
print client.service.getBank("76251020")
|
||||
print(client.service.getBank("76251020"))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
url = "http://arcweb.esri.com/services/v2/RouteFinder.wsdl"
|
||||
start(url)
|
||||
client = Client(url)
|
||||
print client
|
||||
print(client)
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
timer = metrics.Timer()
|
||||
|
@ -264,19 +287,21 @@ try:
|
|||
client = Client(url)
|
||||
#client.setport(0)
|
||||
timer.stop()
|
||||
print 'create client: %s' % timer
|
||||
print('create client: %s' % (timer,))
|
||||
timer.start()
|
||||
s = str(client)
|
||||
timer.stop()
|
||||
print 'str(client): %s' % timer
|
||||
print 'client:\n%s' % s
|
||||
print('str(client): %s' % (timer,))
|
||||
print('client:\n%s' % (s,))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
print '\nFinished: errors = %d' % errors
|
||||
print('\nFinished: errors = %d' % (errors,))
|
||||
|
|
|
@ -14,26 +14,26 @@
|
|||
# written by: Jeff Ortel ( jortel@redhat.com )
|
||||
|
||||
#
|
||||
# This test requires installation or visability to an RHQ server.
|
||||
# This test requires installation or visibility of an RHQ server.
|
||||
# ( http://www.rhq-project.org )
|
||||
#
|
||||
|
||||
import sys
|
||||
sys.path.append('../../')
|
||||
|
||||
import traceback as tb
|
||||
from tests import *
|
||||
from suds import WebFault
|
||||
from suds.client import Client
|
||||
|
||||
import traceback as tb
|
||||
|
||||
|
||||
errors = 0
|
||||
|
||||
|
||||
def start(url):
|
||||
global errors
|
||||
print '\n________________________________________________________________\n'
|
||||
print 'Test @ ( %s ) %d' % (url, errors)
|
||||
print('\n______________________________________________________________\n')
|
||||
print('Test @ ( %s ) %d' % (url, errors))
|
||||
|
||||
|
||||
def rhqTest():
|
||||
|
@ -43,10 +43,9 @@ def rhqTest():
|
|||
url = 'http://localhost.localdomain:7080/rhq-rhq-enterprise-server-ejb3/WebservicesManagerBean?wsdl'
|
||||
start(url)
|
||||
client = Client(url)
|
||||
print client
|
||||
print(client)
|
||||
|
||||
try:
|
||||
|
||||
#
|
||||
# create name
|
||||
#
|
||||
|
@ -77,22 +76,22 @@ def rhqTest():
|
|||
# create a person object using the wsdl
|
||||
#
|
||||
person = client.factory.create('person')
|
||||
print person
|
||||
print(person)
|
||||
person.name = name
|
||||
person.age = 43
|
||||
person.phone.append(phoneA)
|
||||
person.phone.append(phoneB)
|
||||
person.pet.append(dog)
|
||||
person.pet.append(cat)
|
||||
print person
|
||||
print(person)
|
||||
#
|
||||
# addPerson()
|
||||
#
|
||||
print 'addPersion()'
|
||||
print('addPersion()')
|
||||
result = client.service.addPerson(person)
|
||||
sent = client.last_sent()
|
||||
rcvd = client.last_received()
|
||||
print '\nreply(\n%s\n)\n' % result
|
||||
print('\nreply(\n%s\n)\n' % (result,))
|
||||
#
|
||||
# create a new name object used to update the person
|
||||
#
|
||||
|
@ -102,110 +101,124 @@ def rhqTest():
|
|||
#
|
||||
# update the person's name (using the webservice)
|
||||
#
|
||||
print 'updatePersion()'
|
||||
print('updatePersion()')
|
||||
result = client.service.updatePerson(person, newname)
|
||||
print '\nreply(\n%s\n)\n' % str(result)
|
||||
print('\nreply(\n%s\n)\n' % (str(result),))
|
||||
result = client.service.updatePerson(person, None)
|
||||
print '\nreply(\n%s\n)\n' % str(result)
|
||||
print('\nreply(\n%s\n)\n' % (str(result),))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
print "echo('this is cool')"
|
||||
print("echo('this is cool')")
|
||||
result = client.service.echo('this is cool')
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print 'echo(None)'
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
print('echo(None)')
|
||||
result = client.service.echo(None)
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
print 'hello()'
|
||||
print('hello()')
|
||||
result = client.service.hello()
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
print 'testVoid()'
|
||||
print('testVoid()')
|
||||
result = client.service.testVoid()
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
mylist = ['my', 'dog', 'likes', 'steak']
|
||||
print 'testListArgs(%s)' % mylist
|
||||
print('testListArgs(%s)' % (mylist,))
|
||||
result = client.service.testListArg(mylist)
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
s = 'hello'
|
||||
for n in range(0, 3):
|
||||
print 'getList(%s, %d)' % (s, n)
|
||||
print('getList(%s, %d)' % (s, n))
|
||||
result = client.service.getList(s, n)
|
||||
print '\nreply( %s )\n' % str(result)
|
||||
print('\nreply( %s )\n' % (str(result),))
|
||||
if len(result) != n:
|
||||
errors += 1
|
||||
print 'expected (%d), reply (%d)' % (n, len(result))
|
||||
print('expected (%d), reply (%d)' % (n, len(result)))
|
||||
except WebFault, f:
|
||||
errors += 1
|
||||
print f
|
||||
print f.fault
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
try:
|
||||
print 'testExceptions()'
|
||||
print('testExceptions()')
|
||||
result = client.service.testExceptions()
|
||||
print '\nreply( %s )\n' % tostr(result)
|
||||
print('\nreply( %s )\n' % (tostr(result),))
|
||||
raise Exception('Fault expected and not raised')
|
||||
except WebFault, f:
|
||||
print f
|
||||
print f.fault
|
||||
print f.document
|
||||
except Exception, e:
|
||||
print(f)
|
||||
print(f.fault)
|
||||
print(f.document)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
errors += 1
|
||||
print e
|
||||
print(sys.exc_info()[1])
|
||||
tb.print_exc()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
errors = 0
|
||||
rhqTest()
|
||||
print '\nFinished: errors=%d' % errors
|
||||
print('\nFinished: errors=%d' % (errors,))
|
||||
|
|
Loading…
Reference in New Issue