File: test_http_post.py

package info (click to toggle)
python-zeep 4.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,600 kB
  • sloc: python: 15,551; makefile: 13
file content (34 lines) | stat: -rw-r--r-- 942 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os

import pytest
import requests_mock

import zeep

WSDL = os.path.join(os.path.dirname(__file__), "test_http_post.wsdl")


@pytest.mark.requests
def test_get_urlreplacement():
    client = zeep.Client(WSDL)

    with requests_mock.mock() as m:
        m.get("http://example.com/companyinfo/o1/EUR/", text="<root>Hoi</root>")
        result = client.service.o1("EUR")
        assert result == "Hoi"

        history = m.request_history[0]
        assert history._request.path_url == "/companyinfo/o1/EUR/"


@pytest.mark.requests
def test_post_mime_content():
    client = zeep.Client(WSDL, service_name="CompanyInfoService", port_name="Port3")

    with requests_mock.mock() as m:
        m.post("http://example.com/companyinfo/o1", text="<root>Hoi</root>")
        result = client.service.o1("EUR")
        assert result == "Hoi"

        history = m.request_history[0]
        assert history._request.path_url == "/companyinfo/o1"