コード例 #1
0
ファイル: test_google.py プロジェクト: mikejihbe/scio
 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
ファイル: test_styles.py プロジェクト: jpellerin/scio
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
ファイル: test_google.py プロジェクト: mikejihbe/scio
 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
ファイル: test_google.py プロジェクト: mikejihbe/scio
 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
ファイル: test_google.py プロジェクト: mikejihbe/scio
 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
ファイル: test_google.py プロジェクト: mikejihbe/scio
 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
ファイル: test_schema_import.py プロジェクト: bjmc/scio
def mock_urlopen(url):
    fn = url.split('/')[-1]
    return helpers.support(fn, 'r')
コード例 #24
0
ファイル: test_schema_import.py プロジェクト: mikejihbe/scio
def mock_urlopen(url):
    fn = url.split('/')[-1]
    return helpers.support(fn, 'r')
コード例 #25
0
ファイル: test_static_internals.py プロジェクト: bjmc/scio
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
ファイル: test_google.py プロジェクト: mikejihbe/scio
 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
ファイル: test_static_internals.py プロジェクト: bjmc/scio
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
ファイル: test_static_gen.py プロジェクト: bjmc/scio
 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
ファイル: test_schema_import.py プロジェクト: bjmc/scio
 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
ファイル: test_subclassing.py プロジェクト: mikejihbe/scio
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
ファイル: test_subclassing.py プロジェクト: bjmc/scio
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