Пример #1
0
def main():
    servers = DEFAULT_SERVERS_FILE
    methodnums = None
    output = 'f'
    invert = 0
    succeed = 0
    printtrace = 0
    stats = 1
    total = 0
    fail = 0
    failok = 0
    notimp = 0

    try:
        opts, args = getopt.getopt(
            sys.argv[1:], '?dm:io:s:t',
            ['help', 'method', 'debug', 'invert', 'output', 'servers='])
        for opt, arg in opts:
            if opt in ('-?', '--help'):
                usage()
            elif opt in ('-d', '--debug'):
                SOAP.Config.debug = 1
            elif opt in ('-i', '--invert'):
                invert = 1
            elif opt in ('-m', '--method'):
                if arg == '?':
                    methodUsage()
                methodnums = str2list(arg)
            elif opt in ('-o', '--output'):
                output = arg
            elif opt in ('-s', '--servers'):
                servers = arg
            else:
                raise AttributeError(
                    "Recognized but unimplemented option `%s'" % opt)
    except SystemExit:
        raise
    except:
        usage(sys.exc_info()[1])

    if 'a' in output:
        output = 'fFns'

    servers = readServers(servers)

    if methodnums == None:
        methodnums = list(range(1, len(DEFAULT_METHODS) + 1))

    limitre = re.compile('|'.join(args), re.IGNORECASE)

    for s in servers:
        if (not not limitre.match(s['name'])) == invert:
            continue

        serv = SOAP.SOAPProxy(s['endpoint'], namespace=s['namespace'])

        for num in (methodnums):
            if num > len(DEFAULT_METHODS):
                break

            total += 1

            name = DEFAULT_METHODS[num - 1]

            title = '%s: %s (#%d)' % (s['name'], name, num)

            try:
                fn = globals()[name]
            except KeyboardInterrupt:
                raise
            except:
                if 'n' in output:
                    print(title, "test not yet implemented")
                notimp += 1
                continue

            try:
                res = fn(serv, s['soapaction'], s['name'])
                if name in s['nonfunctional']:
                    print(title, "succeeded despite marked nonfunctional")
                elif 's' in output:
                    print(title, "succeeded ")
                succeed += 1
            except KeyboardInterrupt:
                print("fail")
                raise
            except:
                if name in s['nonfunctional']:
                    if 'F' in output:
                        t = 'as expected'
                        if s['nonfunctional'][name] != '':
                            t += ', ' + s['nonfunctional'][name]
                        print(title, "failed (%s) -" % t, sys.exc_info()[1])
                    failok += 1
                else:
                    if 'f' in output:
                        print(title, "failed -", str(sys.exc_info()[1]))
                    fail += 1

    if stats:
        print("   Tests ended at:", time.ctime(time.time()))
        if stats > 0:
            print("        Total tests: %d" % total)
            print("          Successes: %d (%3.2f%%)" % \
                (succeed, 100.0 * succeed / total))
        if stats > 0 or fail > 0:
            print("Failed unexpectedly: %d (%3.2f%%)" % \
                (fail, 100.0 * fail / total))
        if stats > 0:
            print(" Failed as expected: %d (%3.2f%%)" % \
                (failok, 100.0 * failok / total))
        if stats > 0 or notimp > 0:
            print("    Not implemented: %d (%3.2f%%)" % \
                (notimp, 100.0 * notimp / total))

    return fail + notimp
Пример #2
0
def main ():
    stats = 1
    total = 0
    fail = 0
    failok = 0
    succeed = 0
    exitonfailure = 0
    harsh = 0
    invert = 0
    printtrace = 0
    methodnums = None
    notimp = 0
    output = 'f'
    servers = DEFAULT_SERVERS_FILE

    started = time.time ()

    try:
        opts, args = getopt.getopt (sys.argv[1:], '?dehim:nNo:s:tT',
            ['help', 'debug', 'exit-on-failure', 'harsh', 'invert',
                'method', 'no-stats', 'no-statistics',
                'no-boring-statistics', 'no-boring-stats', 'output',
                'servers=', 'stacktrace', 'always-stacktrace'])

        for opt, arg in opts:
            if opt in ('-?', '--help'):
                usage ()
            elif opt in ('-d', '--debug'):
                SOAP.Config.debug = 1
            elif opt in ('-h', '--harsh'):
                harsh = 1
            elif opt in ('-i', '--invert'):
                invert = 1
            elif opt in ('-e', '--exit-on-failure'):
                exitonfailure = 1
            elif opt in ('-m', '--method'):
                if arg == '?':
                    methodUsage ()
                methodnums = str2list (arg)
            elif opt in ('-n', '--no-stats', '--no-statistics'):
                stats = 0
            elif opt in ('-N', '--no-boring-stats', '--no-boring-statistics'):
                stats = -1
            elif opt in ('-o', '--output'):
                output = arg
            elif opt in ('-s', '--servers'):
                servers = arg
            elif opt in ('-t', '--stacktrace'):
                printtrace = 1
            elif opt in ('-T', '--always-stacktrace'):
                printtrace = 2
            else:
                raise AttributeError, \
                     "Recognized but unimplemented option `%s'" % opt
    except SystemExit:
        raise
    except:
        usage (sys.exc_info ()[1])

    if 'a' in output:
        output = 'fFns'

    servers = readServers (servers)

    if methodnums == None:
        methodnums = range (1, len (DEFAULT_METHODS) + 1)

    limitre = re.compile ('|'.join (args), re.IGNORECASE)

    for s in servers:
        if (not not limitre.match (s['name'])) == invert:
            continue

        try: typed = s['typed']
        except: typed = 1

        try: style = s['style']
        except: style = 1999

        SOAP.Config.typed = typed
        SOAP.Config.namespaceStyle = style

        server = SOAP.SOAPProxy (s['endpoint'], ("m", s['namespace']))

        for num in (methodnums):
            if num > len (DEFAULT_METHODS):
                break

            total += 1

            name = DEFAULT_METHODS[num - 1]

            title = '%s: %s (#%d)' % (s['name'], name, num)

            if SOAP.Config.debug:
                print "%s:" % title

            try:
                fn = globals ()['test' + name[0].upper () + name[1:]]
            except KeyboardInterrupt:
                raise
            except:
                if 'n' in output:
                    print title, "test not yet implemented"
                notimp += 1
                continue

            try:
                fn (server, s['soapaction'], harsh)
                if s['nonfunctional'].has_key (name):
                    print title, \
                        "succeeded despite being marked nonfunctional"
                if 's' in output:
                    print title, "succeeded"
                succeed += 1
            except KeyboardInterrupt:
                raise
            except:
                fault = str (sys.exc_info ()[1])
                if fault[-1] == '\n':
                    fault = fault[:-1]

                if s['nonfunctional'].has_key (name):
                    if 'F' in output:
                        t = 'as expected'
                        if s['nonfunctional'][name] != '':
                            t += ', ' + s['nonfunctional'][name]
                        print title, "failed (%s) -" % t, fault
                    if printtrace > 1:
                        traceback.print_exc ()
                    failok += 1
                else:
                    if 'f' in output:
                        print title, "failed -", fault
                    if printtrace:
                        traceback.print_exc ()
                    fail += 1

                    if exitonfailure:
                        return -1

    if stats:
        print "   Tests started at:", time.ctime (started)
        if stats > 0:
            print "        Total tests: %d" % total
            print "          Successes: %d (%3.2f%%)" % \
                (succeed, 100.0 * succeed / total)
        if stats > 0 or fail > 0:
            print "Failed unexpectedly: %d (%3.2f%%)" % \
                (fail, 100.0 * fail / total)
        if stats > 0:
            print " Failed as expected: %d (%3.2f%%)" % \
                (failok, 100.0 * failok / total)
        if stats > 0 or notimp > 0:
            print "    Not implemented: %d (%3.2f%%)" % \
                (notimp, 100.0 * notimp / total)

    return fail + notimp
Пример #3
0
#!/usr/bin/env python

import sys
from SOAPpy import SOAP

# Uncomment to see outgoing HTTP headers and SOAP and incoming SOAP.
SOAP.Config.debug = 1

SOAP.Config.BuildWithNoType = 0
SOAP.Config.BuildWithNoNamespacePrefix = 0

if len(sys.argv) > 1 and sys.argv[1] == '-s':
    server = SOAP.SOAPProxy("https://*****:*****@localhost:8080/",
                            encoding=None)

x = server.sopa()
print(x)
Пример #4
0
#!/usr/bin/env python

import time
from SOAPpy import SOAP

srv = SOAP.SOAPProxy('http://localhost:10080/')

for p in ('good param', 'ok param'):
    ret = srv.badparam(p)
    if isinstance(ret, SOAP.faultType):
        print ret
    else:
        print 'ok'

dt = SOAP.dateTimeType(time.localtime(time.time()))
print srv.dt(dt)



Пример #5
0
methodnum = 1

try:
    opts, args = getopt.getopt(sys.argv[1:], 'p:m:', ['method', 'port'])
    for opt, arg in opts:
        if opt in ('-m', '--method'):
            if arg == '?':
                methodUsage()
            methodnum = int(arg)
        elif opt in ('-p', '--port'):
            port = int(arg)
        else:
            raise AttributeError, "Recognized but unimpl option '%s'" % opt
except SystemExit:
    raise
except:
    usage()

ep = "http://208.177.157.221:%d/xmethodsInterop" % (port)
sa = "urn:soapinterop"
ns = "http://www.soapinterop.org/Bid"

serv = SOAP.SOAPProxy(ep, namespace=ns, soapaction=sa)
if methodnum == 1:
    print serv.Monitor(str="actzero")
elif methodnum == 2:
    print serv.Clear(str="actzero")
else:
    print "invalid methodnum"
    methodUsage()