Esempio n. 1
0
def test_xml():
    wst = WSTest()

    response = wst.on(
        'http://www.w3schools.com/webservices/tempconvert.asmx/CelsiusToFahrenheit',
        headers={
            'Content-Type': 'application/x-www-form-urlencoded'
        }).post(Request('Celsius=-40'))

    assert response.at('/tmp:string', {'tmp': 'http://tempuri.org/'}) == '-40'
Esempio n. 2
0
def test_soap():
    wst = WSTest()
    wst.nsmapping = {'soap': 'http://www.w3.org/2003/05/soap-envelope'}

    response = wst.on('http://www.w3schools.com/webservices/tempconvert.asmx',
                      headers={
                          'Content-Type': 'application/soap+xml'
                      }).post(
                          wst.file('{0}/test_core.soap12'.format(
                              os.path.dirname(__file__))))

    assert response.at(
        '/soap:Envelope/soap:Body/tmp:CelsiusToFahrenheitResponse/tmp:CelsiusToFahrenheitResult',
        {'tmp': 'http://tempuri.org/'}) == '-4.9'

    assert response.at(
        '/tmp:CelsiusToFahrenheitResponse/tmp:CelsiusToFahrenheitResult',
        {'tmp': 'http://tempuri.org/'}) == '-4.9'
Esempio n. 3
0
def test_json():
    wst = WSTest()
    response = wst.on(
        'http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo'
    ).get()
    assert response.at('/geonames[1]/name') == 'Mexico City'