Esempio n. 1
0
def test_load_file():
    cache = stub(get=lambda url: None, add=lambda url, content: None)
    transport = transports.Transport(cache=cache)
    with patch("io.open", mock_open(read_data=b"x")) as m_open:
        result = transport.load("file:///usr/local/bin/example.wsdl")
        assert result == b"x"
        m_open.assert_called_once_with("/usr/local/bin/example.wsdl", "rb")
Esempio n. 2
0
def test_load():
    cache = stub(get=lambda url: None, add=lambda url, content: None)
    transport = transports.Transport(cache=cache)

    with requests_mock.mock() as m:
        m.get('http://tests.python-zeep.org/test.xml', text='x')
        result = transport.load('http://tests.python-zeep.org/test.xml')

        assert result == b'x'
Esempio n. 3
0
def test_settings_set_context_timeout():
    transport = transports.Transport(cache=cache)

    assert transport.operation_timeout is None
    with transport.settings(timeout=120):
        assert transport.operation_timeout == 120

        with transport.settings(timeout=90):
            assert transport.operation_timeout == 90
        assert transport.operation_timeout == 120
    assert transport.operation_timeout is None
Esempio n. 4
0
    def __init__(self,
                 instance=None,
                 clientid=None,
                 secretkey=None,
                 sandbox="false",
                 locale="nl_NL",
                 demo="false"):
        try:
            if clientid is None:
                raise Exception("No client id provided")

            self.clientid = clientid

            if secretkey is None:
                raise Exception("No secret key provided")

            self.secretkey = secretkey

            self.sandbox = sandbox
            self.locale = locale
            self.demo = demo

            self.instance = instance
            self.session = requests.Session()
            self.transport = transports.Transport(session=self.session)

            wsdl_url = 'http://ws.tradetracker.com/soap/affiliate?wsdl'

            self.client = Client(wsdl_url, transport=self.transport)
            self.client.service.authenticate(self.clientid, self.secretkey,
                                             self.sandbox, self.locale,
                                             self.demo)

        except Exception as e:
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            logging.warning(
                str(e) + " | " + str(exc_type) + " | " + str(fname) + " | " +
                str(exc_tb.tb_lineno))
Esempio n. 5
0
def test_default_cache():
    transport = transports.Transport()
    assert isinstance(transport.cache, cache.SqliteCache)
Esempio n. 6
0
def test_no_cache():
    transport = transports.Transport(cache=None)
    assert transport.cache is None
Esempio n. 7
0
def test_custom_cache():
    transport = transports.Transport(cache=cache.SqliteCache())
    assert isinstance(transport.cache, cache.SqliteCache)