Ejemplo n.º 1
0
 def clientClass(self, wsdl):
     cl = scio.Client(wsdl)
     code = gen.gen(cl)
     ns = {}
     exec code in ns
     cls = type('StaticStub', (StubClient, ns['Client']), {})
     return cls()
Ejemplo n.º 2
0
def test_iter_empty():
    lw = scio.Client(helpers.support('lyrics.wsdl'))
    song = lw.type.SongResult()
    c = 0
    for p in song:
        c += 1
    assert c == 0, "Empty type iter yielded items"
Ejemplo n.º 3
0
def test_iter_over_self():
    lw = scio.Client(helpers.support('lyrics.wsdl'))
    song = lw.type.SongResult(artist='Prince', song='Nothing Compares 2 U')

    c = 0
    for s in song:
        assert s.song == 'Nothing Compares 2 U'
        c += 1
    assert c == 1, "Self iter yield <> 1 item"
Ejemplo n.º 4
0
def test_fault_includes_detail_if_set():
    try:
        lw = scio.Client(helpers.support('lyrics.wsdl', 'r'))
        fr = """<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><env:Fault xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><faultcode>env:Server</faultcode><faultstring>java.lang.NullPointerException</faultstring><detail>Got bitten by monkey</detail></env:Fault></env:Body></env:Envelope>"""
        e = HTTPError("http://foo", 500, "Server Error", {}, StringIO(fr))
        lw.handle_error(lw.service.getArtist.method, e)
    except scio.Fault, f:
        print str(f)
        assert f.detail
Ejemplo n.º 5
0
def test_instantiate_complex_type_with_dict():
    lw = scio.Client(helpers.support('lyrics.wsdl'))
    album = lw.type.AlbumResult({
        'artist': 'Wilco',
        'album': 'Summerteeth',
        'year': 1999
    })
    assert album.artist == 'Wilco'
    assert album.album == 'Summerteeth'
    assert album.year == 1999
Ejemplo n.º 6
0
def test_rpc_enc_includes_type_attrib():
    lw = scio.Client(helpers.support('lyrics.wsdl', 'r'))
    req = lw.service.checkSongExists.method.input('prince', '1999').toxml()
    c = etree.Element('c')
    for e in req:
        c.append(e)
    req_xml = etree.tostring(c)
    print req_xml
    artist = c[0][0]
    print artist.attrib
    assert artist.attrib
Ejemplo n.º 7
0
 def test_header_unmarshalling(self):
     client = scio.Client(
         helpers.support('adwords_trafficestimatorservice.wsdl', 'r'))
     response = helpers.support('adwords_response_example.xml', 'r').read()
     result, headers = client.handle_response(
         client.service.estimateKeywordList.method,
         response)
     print result
     print headers
     assert headers['operations'] == 1
     assert headers['responseTime'] == 10636
     assert headers['units'] == 1
     assert 'eb21e6667abb131c117b58086f75abbd' in headers['requestId']
Ejemplo n.º 8
0
def test_list_unmarshalling():
    lw = scio.Client(helpers.support('lyrics.wsdl', 'r'))
    rsp = etree.fromstring(helpers.support('lyric_rsp.xml', 'r').read())[0][0]
    print rsp
    artist, albums = lw.service.getArtist.method.output(rsp)
    print artist, albums
    assert albums
    eq_(len(albums), 22)
    boy = albums[0]
    eq_(boy.album, u'Boy')
    eq_(boy.year, 1980)
    eq_(len(boy.songs), 11)
    eq_(boy.songs[0], u'I Will Follow')
    eq_(boy.songs[10], u'Shadows And Tall Trees')
Ejemplo n.º 9
0
 def run(self):
     wsdl_file = self.arguments[0]
     self.ns = self.options.get('namespace', self.ns_from_file(wsdl_file))
     self.client = scio.Client(open(wsdl_file,
                                    'r'))  # FIXME accept urls too?
     rst = self.doc()
     state = self.state
     node = nodes.section()
     surrounding_title_styles = state.memo.title_styles
     surrounding_section_level = state.memo.section_level
     state.memo.title_styles = []
     state.memo.section_level = 0
     state.nested_parse(rst, 0, node, match_titles=1)
     state.memo.title_styles = surrounding_title_styles
     state.memo.section_level = surrounding_section_level
     return node.children
Ejemplo n.º 10
0
def test_empty_complextype_not_true():
    lw = scio.Client(helpers.support('lyrics.wsdl'))
    song = lw.type.SongResult()
    assert not song
Ejemplo n.º 11
0
def test_no_soap_body_in_xml_response_raises_notsoap():
    lw = scio.Client(helpers.support('lyrics.wsdl', 'r'))
    er = "<a/>"
    lw.handle_response(None, er)
Ejemplo n.º 12
0
def test_handle_error_with_blank_body():
    lw = scio.Client(helpers.support('lyrics.wsdl', 'r'))
    fr = "<a/>"
    e = HTTPError("http://foo", 500, "Server Error", {}, StringIO(fr))
    lw.handle_error(lw.service.getArtist.method, e)
Ejemplo n.º 13
0
def test_deserialize_boyzoid_response():
    client = scio.Client(helpers.support('boyzoid.wsdl', 'r'))
    response = etree.parse(helpers.support('bz_response.xml', 'r')).getroot()
    quote = client.service.getQuote.method.output(response)
    print quote, quote.item
    print quote.item[1].value
Ejemplo n.º 14
0
def test_handle_error_raises_fault():
    lw = scio.Client(helpers.support('lyrics.wsdl', 'r'))
    fr = """<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><env:Fault xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><faultcode>env:Server</faultcode><faultstring>java.lang.NullPointerException</faultstring></env:Fault></env:Body></env:Envelope>"""
    e = HTTPError("http://foo", 500, "Server Error", {}, StringIO(fr))
    lw.handle_error(lw.service.getArtist.method, e)
Ejemplo n.º 15
0
def test_parse_shoppingservice():
    client = scio.Client(helpers.support('shoppingservice.wsdl', 'r'))
Ejemplo n.º 16
0
def test_enum_restriction_not_first_element():
    zf = scio.Client(helpers.support('zfapi.wsdl', 'r'))
    print zf.type.ApiAccessMask._values
    assert zf.type.ApiAccessMask._values
Ejemplo n.º 17
0
def test_parse_jira():
    client = scio.Client(helpers.support('jira.wsdl', 'r'))
Ejemplo n.º 18
0
def test_zfapi_is_document_literal_wrapper():
    zf = scio.Client(helpers.support('zfapi.wsdl', 'r'))
    eq_(zf.service.Authenticate.method.input.formatter,
        scio.client.DocumentLiteralWrapperInputFormatter)
Ejemplo n.º 19
0
    e = HTTPError("http://foo", 500, "Server Error", {}, StringIO(fr))
    lw.handle_error(lw.service.getArtist.method, e)


def test_fault_includes_detail_if_set():
    try:
        lw = scio.Client(helpers.support('lyrics.wsdl', 'r'))
        fr = """<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><env:Fault xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><faultcode>env:Server</faultcode><faultstring>java.lang.NullPointerException</faultstring><detail>Got bitten by monkey</detail></env:Fault></env:Body></env:Envelope>"""
        e = HTTPError("http://foo", 500, "Server Error", {}, StringIO(fr))
        lw.handle_error(lw.service.getArtist.method, e)
    except scio.Fault, f:
        print str(f)
        assert f.detail

    try:
        lw = scio.Client(helpers.support('lyrics.wsdl', 'r'))
        fr = """<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><env:Fault xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><faultcode>env:Server</faultcode><faultstring>java.lang.NullPointerException</faultstring></env:Fault></env:Body></env:Envelope>"""
        e = HTTPError("http://foo", 500, "Server Error", {}, StringIO(fr))
        lw.handle_error(lw.service.getArtist.method, e)
    except scio.Fault, f:
        print str(f)
        assert not f.detail


def test_instantiate_complex_type_with_string():
    snx = scio.Client(helpers.support('synxis.wsdl'))
    price = snx.type.MarketSegment('Irate organists', MarketSegmentCode='IRO')
    assert price._content == 'Irate organists'
    assert price.MarketSegmentCode == 'IRO'

Ejemplo n.º 20
0
def getOrders(request):
    try:
        returnData = {
            "status": "",
            "recordcount": "",
            "success": 0,
            "message": "",
            "orders": ""
        }

        aryFormKeys = ["apikey", "secretkey", "customerid", "status", "token"]
        formValues = helpers.getFormValues(request, "POST", aryFormKeys)
        apikey, secretkey, customerid, status, token = [
            formValues.get(k) for k in aryFormKeys
        ]

        if token is None or customerid is None:
            returnData = {
                "status": "",
                "recordcount": "",
                "orders": "",
                "success": 0,
                "message": "Token degeri gonderilmedi"
            }
        else:
            token_check = helpers.tokenCheck(token, customerid)
            if token_check["success"] == 0:
                returnData = {
                    "status": "",
                    "recordcount": "",
                    "orders": "",
                    "success": 0,
                    "message": token_check["message"]
                }
            else:
                if apikey is not None and secretkey is not None and status is not None:
                    wsdl = 'https://api.n11.com/ws/OrderService.wsdl'

                    import scio
                    import urllib2
                    client = scio.Client(urllib2.urlopen(wsdl))

                    fauth = client.type.Authentication()
                    fauth.appKey = apikey
                    fauth.appSecret = secretkey

                    fperiod = client.type.OrderSearchPeriod()
                    fperiod.startDate = ""
                    fperiod.endDate = ""

                    fsearchData = client.type.OrderDataListRequest()
                    #fsearchData.productId = ''
                    fsearchData.status = status
                    fsearchData.buyerName = ""
                    fsearchData.orderNumber = ""
                    fsearchData.productSellerCode = ""
                    fsearchData.recipient = ""
                    fsearchData.sameDayDelivery = ""
                    fsearchData.period = fperiod

                    fpagingData = client.type.PagingData()
                    fpagingData.currentPage = 0
                    fpagingData.pageSize = 1
                    fpagingData.totalCount = 100
                    fpagingData.pageCount = 1

                    rresult = None
                    response = client.service.DetailedOrderList(
                        auth=fauth,
                        searchData=fsearchData,
                        pagingData=fpagingData)
                    if hasattr(response, "result"):
                        rresult = response.result
                        if hasattr(rresult, "status"):
                            rstatus = str(rresult.status).strip()
                            if rstatus == "success":
                                if hasattr(response, "pagingData"):
                                    pagingData = response.pagingData
                                    if hasattr(pagingData, "totalCount"):
                                        totalCount = pagingData.totalCount
                                        if totalCount == 0:
                                            returnData = {
                                                "status": status,
                                                "recordcount": totalCount,
                                                "success": 1,
                                                "message": "islem basarili"
                                            }
                                        else:
                                            if hasattr(response, "orderList"):
                                                orderList = response.orderList
                                                if hasattr(orderList, "order"):
                                                    order = orderList.order
                                                    fullOrderData = []
                                                    for orderRec in order:
                                                        responseJson = {}
                                                        #RcreateDate, Rid, RorderNumber, RpaymentType, Rstatus, RtotalAmount = ""
                                                        if hasattr(
                                                                orderRec,
                                                                "createDate"):
                                                            RcreateDate = str(
                                                                orderRec.
                                                                createDate)
                                                        if hasattr(
                                                                orderRec,
                                                                "id"):
                                                            Rid = str(
                                                                orderRec.id)
                                                        if hasattr(
                                                                orderRec,
                                                                "orderNumber"):
                                                            RorderNumber = str(
                                                                orderRec.
                                                                orderNumber)
                                                        if hasattr(
                                                                orderRec,
                                                                "paymentType"):
                                                            RpaymentType = str(
                                                                orderRec.
                                                                paymentType)
                                                        if hasattr(
                                                                orderRec,
                                                                "status"):
                                                            Rstatus = str(
                                                                orderRec.status
                                                            )
                                                        if hasattr(
                                                                orderRec,
                                                                "totalAmount"):
                                                            RtotalAmount = str(
                                                                orderRec.
                                                                totalAmount)

                                                        responseJson[
                                                            "createDate"] = RcreateDate
                                                        responseJson[
                                                            "orderid"] = Rid
                                                        responseJson[
                                                            "orderNumber"] = RorderNumber
                                                        responseJson[
                                                            "paymentType"] = RpaymentType
                                                        responseJson[
                                                            "orderstatus"] = Rstatus
                                                        responseJson[
                                                            "totalAmount"] = RtotalAmount

                                                        fullOrderData.append(
                                                            responseJson)

                                                        returnData = {
                                                            "status":
                                                            "",
                                                            "recordcount":
                                                            totalCount,
                                                            "success":
                                                            1,
                                                            "orders":
                                                            str(fullOrderData),
                                                            "message":
                                                            "islem basarili"
                                                        }
                                                else:
                                                    print(
                                                        "::::::::::orderorderorderorder:::"
                                                    )
                                            else:
                                                print(
                                                    "::::::::::orderListorderListorderList:::"
                                                )
                            else:
                                returnData = {
                                    "status": "",
                                    "recordcount": "",
                                    "orders": "",
                                    "success": 0,
                                    "message":
                                    "n11:" + str(rresult.errorMessage)
                                }
                    else:
                        returnData = {
                            "status": "",
                            "recordcount": "",
                            "success": 0,
                            "message": "API den cevap donmedi",
                            "orders": ""
                        }
                else:
                    returnData = {
                        "status": "",
                        "recordcount": "",
                        "success": 0,
                        "message":
                        "API parametrelerini kontrol ediniz.[inf0x12903]",
                        "orders": ""
                    }
    except Exception, Argument:
        print("::::::::::ExceptionException")
        print("::::::::::ExceptionException")
        errorText = ""
        if Argument is None:
            # Try/Catch den donen arguman degeri null.
            errorText = "Hata aciklamasi elde edilemedi [err0x12904]"
        else:
            errorText = str(Argument) + "[err0x12905]"

        returnData = {
            "status": "",
            "recordcount": "",
            "success": 0,
            "message": errorText,
            "orders": ""
        }
Ejemplo n.º 21
0
def test_instantiate_complex_type_with_string():
    snx = scio.Client(helpers.support('synxis.wsdl'))
    price = snx.type.MarketSegment('Irate organists', MarketSegmentCode='IRO')
    assert price._content == 'Irate organists'
    assert price.MarketSegmentCode == 'IRO'
Ejemplo n.º 22
0
import scio
import helpers
from lxml import etree


def transport(req):
    return helpers.support('NilDateResp.xml', 'r')


client = scio.Client(helpers.support('NilDate.wsdl', 'r'),
                     transport=transport)


def test_simple_date():
    notnil = client.type.getNilDateResponse('2013-03-05')
    assert notnil.year == 2013
    assert notnil.month == 3
    assert notnil.day == 5


def test_nil_simple_date():
    nil = client.type.getNilDateResponse()
    assert nil is None


def test_simple_datetime():
    notnil = client.type.getNilDateTimeResponse('2013-03-05T12:01:02')
    assert notnil.year == 2013
    assert notnil.month == 3
    assert notnil.day == 5
    assert notnil.hour == 12
Ejemplo n.º 23
0
def test_parse_ebaysvc():
    st = time.time()
    client = scio.Client(helpers.support('eBaySvc.wsdl', 'r'))
    taken = time.time() - st
    print "parsed 4.2mb wsdl in", taken
Ejemplo n.º 24
0
 def __init__(self, username, password):
     self.client = scio.Client(urllib2.urlopen(WSDL))
     self.username = username
     self.password = password
     self.token = None
     self.last_response = None
Ejemplo n.º 25
0
from lxml import etree
from cPickle import dumps, loads
from nose.tools import eq_

import scio
import helpers


def lw_reviver(classname, proto=object, args=()):
    return proto.__new__(getattr(lw.type, classname), *args)


lw = scio.Client(helpers.support('lyrics.wsdl', 'r'),
                 reduce_callback=lw_reviver
                 )


def zf_reviver(classname, proto=object, args=()):
    return proto.__new__(getattr(zf.type, classname), *args)


zf = scio.Client(helpers.support('zfapi.wsdl', 'r'),
                 reduce_callback=zf_reviver
                 )


def test_pickle_and_unpickle_single_type():
    album = lw.type.AlbumResult(
        artist='The Mountain Goats',
        album='The Life of the World to Come',
        year=2009)