예제 #1
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']
예제 #2
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')
예제 #3
0
파일: test_internals.py 프로젝트: bjmc/scio
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')
예제 #4
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"
예제 #5
0
파일: test_internals.py 프로젝트: bjmc/scio
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"
예제 #6
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"
예제 #7
0
파일: test_internals.py 프로젝트: bjmc/scio
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"
예제 #8
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
예제 #9
0
파일: test_internals.py 프로젝트: bjmc/scio
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
예제 #10
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
예제 #11
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
예제 #12
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
예제 #13
0
def test_pickle_unpickle_array():
    rsp = etree.fromstring(helpers.support("lyric_rsp.xml", "r").read())[0][0]
    print rsp
    artist, albums = lw.service.getArtist.method.output(rsp)
    boy = albums[0]
    pickled_boy = dumps(boy)
    unpickled_boy = loads(pickled_boy)

    eq_(unpickled_boy.album, u"Boy")
    eq_(unpickled_boy.year, 1980)
    eq_(len(unpickled_boy.songs), 11)
    eq_(unpickled_boy.songs[0], u"I Will Follow")
    eq_(unpickled_boy.songs[10], u"Shadows And Tall Trees")
예제 #14
0
def test_pickle_unpickle_array():
    rsp = etree.fromstring(helpers.support('lyric_rsp.xml', 'r').read())[0][0]
    print rsp
    artist, albums = lw.service.getArtist.method.output(rsp)
    boy = albums[0]
    pickled_boy = dumps(boy)
    unpickled_boy = loads(pickled_boy)

    eq_(unpickled_boy.album, u'Boy');
    eq_(unpickled_boy.year, 1980)
    eq_(len(unpickled_boy.songs), 11)
    eq_(unpickled_boy.songs[0], u'I Will Follow')
    eq_(unpickled_boy.songs[10], u'Shadows And Tall Trees')
예제 #15
0
 def test_serviced_accounts_service(self):
     # checking that elements in request are produced with
     # the correct namespaces attached.
     client = self.clientClass(
         helpers.support('ServicedAccountService.wsdl', 'r'))
     asel = client.type.ServicedAccountSelector(
         enablePaging=False)
     client.service.get(selector=asel, **self.headers)
     request = StubClient.sent[0][1].data
     print request
     parsed = etree.fromstring(request)
     assert parsed.find('.//{%s}authToken' % self.cm_tns) is not None
     assert parsed.find('.//{%s}authToken' % self.cm_tns).text == self.auth_token
     assert parsed.find('.//{%s}RequestHeader' % self.mcm_tns) is not None
예제 #16
0
 def test_get_all_campaigns(self):
     client = self.clientClass(helpers.support('adwords_campaignservice.wsdl', 'r'))
     client.service.getAllAdWordsCampaigns(dummy=0,
                                           useragent="foo (mozilla)",
                                           email="*****@*****.**",
                                           clientEmail="*****@*****.**",
                                           clientCustomerId="5",
                                           developerToken="99dt",
                                           applicationToken="12at")
     request = StubClient.sent[0][1].data
     print request
     assert 'getAllAdWordsCampaigns' in request
     parsed = etree.fromstring(request)
     assert parsed[1][0][0].tag == '{https://adwords.google.com/api/adwords/v12}dummy'
예제 #17
0
 def test_infoservice_daterange_namespace(self):
     client = self.clientClass(helpers.support('InfoService.wsdl', 'r'))
     isel = client.type.InfoSelector(
         dateRange=client.type.DateRange(
             min='20111101', max='20111130'),
         apiUsageType='UNIT_COUNT')
     eq_(client.type.InfoSelector._namespace,
         "https://adwords.google.com/api/adwords/info/v201101")
     # container assigned to part in new namespace takes on
     # namespace from the context it is assigned to
     eq_(isel.dateRange._namespace,
         "https://adwords.google.com/api/adwords/info/v201101")
     # ... items in the type container keep their namespace
     eq_(isel.dateRange.min._namespace,
         "https://adwords.google.com/api/adwords/cm/v201101")
예제 #18
0
 def test_method_call_with_headers(self):
     client = self.clientClass(helpers.support('adwords_campaignservice.wsdl', 'r'))
     client.service.getCampaign(id=1,
                                useragent="foo (mozilla)",
                                email="*****@*****.**",
                                clientEmail="*****@*****.**",
                                clientCustomerId="5",
                                developerToken="99dt",
                                applicationToken="12at"
                                )
     print StubClient.sent
     request = StubClient.sent[0][1].data
     print request
     assert 'email>' in request
     assert '*****@*****.**' in request
     assert '99dt' in request
     assert '12at' in request
     assert 'foo (mozilla)'
예제 #19
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)
예제 #20
0
def test_array_detection():
    lw = scio.client.Factory(helpers.support('lyrics.wsdl', 'r'))
    aos = lw.wsdl.xpath("//*[@name='ArrayOfstring']")[0]
    print aos
    assert lw._is_array(aos)
예제 #21
0
파일: test_internals.py 프로젝트: bjmc/scio
def test_array_detection():
    lw = scio.client.Factory(helpers.support('lyrics.wsdl', 'r'))
    aos = lw.wsdl.xpath("//*[@name='ArrayOfstring']")[0]
    print aos
    assert lw._is_array(aos)
예제 #22
0
def test_empty_complextype_not_true():
    lw = scio.Client(helpers.support('lyrics.wsdl'))
    song = lw.type.SongResult()
    assert not song
예제 #23
0
def mock_urlopen(url):
    fn = url.split('/')[-1]
    return helpers.support(fn, 'r')
예제 #24
0
def mock_urlopen(url):
    fn = url.split('/')[-1]
    return helpers.support(fn, 'r')
예제 #25
0
def test_deserialize_boyzoid_response():
    response = etree.parse(helpers.support('bz_response.xml', 'r')).getroot()
    quote = M['bz'].Client().service.getQuote.method.output(response)
    print quote, quote.item
    print quote.item[1].value
예제 #26
0
파일: test_internals.py 프로젝트: bjmc/scio
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)
예제 #27
0
 def test_parse_adwords(self):
     self.clientClass(helpers.support('adwords_campaignservice.wsdl', 'r'))
예제 #28
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)
예제 #29
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'
예제 #30
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'
예제 #31
0
 def check(wsdl):
     code = gen.gen(client.Client(helpers.support(wsdl)))
     ns = {}
     print code
     exec code in ns
예제 #32
0
def transport(req):
    return helpers.support('NilDateResp.xml', 'r')
예제 #33
0
파일: test_internals.py 프로젝트: bjmc/scio
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)
예제 #34
0
 def setUp(self):
     self.urlopen = scio.client.urlopen
     scio.client.urlopen = mock_urlopen
     self.client = scio.client.Client(
         helpers.support('CampaignManagementService.wsdl', 'r'))
예제 #35
0
def test_parse_jira():
    client = scio.Client(helpers.support('jira.wsdl', 'r'))
예제 #36
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'

예제 #37
0
def test_calls_get_foo():
    c = FooingClient(helpers.support('lyrics.wsdl'))
    c.service.getArtist('U2', foo='electric!')
예제 #38
0
파일: test_internals.py 프로젝트: bjmc/scio
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)
예제 #39
0
 def check(wsdl):
     code = gen.gen(client.Client(helpers.support(wsdl)))
     ns = {}
     print code
     exec code in ns
예제 #40
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
예제 #41
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
예제 #42
0
파일: test_internals.py 프로젝트: bjmc/scio
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
예제 #43
0
def test_parse_shoppingservice():
    client = scio.Client(helpers.support('shoppingservice.wsdl', 'r'))
예제 #44
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)
예제 #45
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
예제 #46
0
파일: test_internals.py 프로젝트: bjmc/scio
def test_empty_complextype_not_true():
    lw = scio.Client(helpers.support('lyrics.wsdl'))
    song = lw.type.SongResult()
    assert not song
예제 #47
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
예제 #48
0
def test_calls_get_foo():
    c = FooingClient(helpers.support('lyrics.wsdl'))
    c.service.getArtist('U2', foo='electric!')
예제 #49
0
파일: test_internals.py 프로젝트: bjmc/scio
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