debian-zeep/debian/patches/01-remove-failing-tests.patch

267 lines
8.7 KiB
Diff

Description: Remove some failing tests due to missing build dependencies
The following tests fail due to missing build dependencies
tests/test_wsse_signature.py: xmlsec
tests/test_asyncio_transport.py: aioresponses
The following test(s) seem to fail for poor support of asyncio/tornado.
In the hope the package still is for more use even with buggy tornado support
than to keep it out of testing we disable also:
tests/test_tornado_transport.py
s.a. https://github.com/mvantellingen/python-zeep/issues/679
Author: Mathias Behrle <mbehrle@debian.org>
Forwarded: https://github.com/mvantellingen/python-zeep/issues/724
--- a/tests/test_wsse_signature.py
+++ /dev/null
@@ -1,112 +0,0 @@
-import os
-import sys
-
-import pytest
-
-from tests.utils import load_xml
-from zeep import wsse
-from zeep.exceptions import SignatureVerificationFailed
-from zeep.wsse import signature
-
-DS_NS = 'http://www.w3.org/2000/09/xmldsig#'
-
-
-KEY_FILE = os.path.join(
- os.path.dirname(os.path.realpath(__file__)), 'cert_valid.pem')
-KEY_FILE_PW = os.path.join(
- os.path.dirname(os.path.realpath(__file__)), 'cert_valid_pw.pem')
-
-
-@pytest.mark.skipif(sys.platform == 'win32',
- reason="does not run on windows")
-def test_sign():
- envelope = load_xml("""
- <soapenv:Envelope
- xmlns:tns="http://tests.python-zeep.org/"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
- <soapenv:Header></soapenv:Header>
- <soapenv:Body>
- <tns:Function>
- <tns:Argument>OK</tns:Argument>
- </tns:Function>
- </soapenv:Body>
- </soapenv:Envelope>
- """)
-
- signature.sign_envelope(envelope, KEY_FILE, KEY_FILE)
- signature.verify_envelope(envelope, KEY_FILE)
-
-
-@pytest.mark.skipif(sys.platform == 'win32',
- reason="does not run on windows")
-def test_sign_pw():
- envelope = load_xml("""
- <soapenv:Envelope
- xmlns:tns="http://tests.python-zeep.org/"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
- <soapenv:Header></soapenv:Header>
- <soapenv:Body>
- <tns:Function>
- <tns:Argument>OK</tns:Argument>
- </tns:Function>
- </soapenv:Body>
- </soapenv:Envelope>
- """)
-
- signature.sign_envelope(envelope, KEY_FILE_PW, KEY_FILE_PW, 'geheim')
- signature.verify_envelope(envelope, KEY_FILE_PW)
-
-
-@pytest.mark.skipif(sys.platform == 'win32',
- reason="does not run on windows")
-def test_verify_error():
- envelope = load_xml("""
- <soapenv:Envelope
- xmlns:tns="http://tests.python-zeep.org/"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
- <soapenv:Header></soapenv:Header>
- <soapenv:Body>
- <tns:Function>
- <tns:Argument>OK</tns:Argument>
- </tns:Function>
- </soapenv:Body>
- </soapenv:Envelope>
- """)
-
- signature.sign_envelope(envelope, KEY_FILE, KEY_FILE)
- nsmap = {'tns': 'http://tests.python-zeep.org/'}
-
- for elm in envelope.xpath('//tns:Argument', namespaces=nsmap):
- elm.text = 'NOT!'
-
- with pytest.raises(SignatureVerificationFailed):
- signature.verify_envelope(envelope, KEY_FILE)
-
-
-@pytest.mark.skipif(sys.platform == 'win32',
- reason="does not run on windows")
-def test_signature():
- envelope = load_xml("""
- <soapenv:Envelope
- xmlns:tns="http://tests.python-zeep.org/"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
- <soapenv:Header></soapenv:Header>
- <soapenv:Body>
- <tns:Function>
- <tns:Argument>OK</tns:Argument>
- </tns:Function>
- </soapenv:Body>
- </soapenv:Envelope>
- """)
-
- plugin = wsse.Signature(KEY_FILE_PW, KEY_FILE_PW, 'geheim')
- envelope, headers = plugin.apply(envelope, {})
- plugin.verify(envelope)
--- a/tests/test_asyncio_transport.py
+++ /dev/null
@@ -1,76 +0,0 @@
-import aiohttp
-import pytest
-from aioresponses import aioresponses
-from lxml import etree
-from pretend import stub
-
-from zeep import asyncio, exceptions
-
-
-@pytest.mark.requests
-def test_no_cache(event_loop):
- transport = asyncio.AsyncTransport(loop=event_loop)
- assert transport.cache is None
-
-
-@pytest.mark.requests
-def test_load(event_loop):
- cache = stub(get=lambda url: None, add=lambda url, content: None)
- transport = asyncio.AsyncTransport(loop=event_loop, cache=cache)
-
- with aioresponses() as m:
- m.get('http://tests.python-zeep.org/test.xml', body='x')
- result = transport.load('http://tests.python-zeep.org/test.xml')
- assert result == b'x'
-
-
-@pytest.mark.requests
-@pytest.mark.asyncio
-async def test_post(event_loop):
- cache = stub(get=lambda url: None, add=lambda url, content: None)
- transport = asyncio.AsyncTransport(loop=event_loop, cache=cache)
-
- envelope = etree.Element('Envelope')
-
- with aioresponses() as m:
- m.post('http://tests.python-zeep.org/test.xml', body='x')
- result = await transport.post_xml(
- 'http://tests.python-zeep.org/test.xml',
- envelope=envelope,
- headers={})
-
- assert result.content == b'x'
-
-
-@pytest.mark.requests
-@pytest.mark.asyncio
-async def test_session_close(event_loop):
- transport = asyncio.AsyncTransport(loop=event_loop)
- session = transport.session # copy session object from transport
- del transport
- assert session.closed
-
-
-@pytest.mark.requests
-@pytest.mark.asyncio
-async def test_session_no_close(event_loop):
- session = aiohttp.ClientSession(loop=event_loop)
- transport = asyncio.AsyncTransport(loop=event_loop, session=session)
- del transport
- assert not session.closed
-
-
-@pytest.mark.requests
-def test_http_error(event_loop):
- transport = asyncio.AsyncTransport(loop=event_loop)
-
- with aioresponses() as m:
- m.get(
- 'http://tests.python-zeep.org/test.xml',
- body='x',
- status=500,
- )
- with pytest.raises(exceptions.TransportError) as exc:
- transport.load('http://tests.python-zeep.org/test.xml')
- assert exc.value.status_code == 500
- assert exc.value.message is None
--- a/tests/test_tornado_transport.py
+++ /dev/null
@@ -1,57 +0,0 @@
-import pytest
-from lxml import etree
-from mock import patch
-from pretend import stub
-from tornado.concurrent import Future
-from tornado.httpclient import HTTPRequest, HTTPResponse
-from tornado.testing import AsyncTestCase, gen_test
-
-from zeep.tornado import TornadoAsyncTransport
-
-
-class TornadoAsyncTransportTest(AsyncTestCase):
- @pytest.mark.requests
- def test_no_cache(self):
- transport = TornadoAsyncTransport()
- assert transport.cache is None
-
- @pytest.mark.requests
- @patch('tornado.httpclient.HTTPClient.fetch')
- @gen_test
- def test_load(self, mock_httpclient_fetch):
- cache = stub(get=lambda url: None, add=lambda url, content: None)
- response = HTTPResponse(HTTPRequest('http://tests.python-zeep.org/test.xml'), 200)
- response.buffer = True
- response._body = 'x'
- mock_httpclient_fetch.return_value = response
-
- transport = TornadoAsyncTransport(cache=cache)
-
- result = transport.load('http://tests.python-zeep.org/test.xml')
-
- assert result == 'x'
-
- @pytest.mark.requests
- @patch('tornado.httpclient.AsyncHTTPClient.fetch')
- @gen_test
- def test_post(self, mock_httpclient_fetch):
- cache = stub(get=lambda url: None, add=lambda url, content: None)
-
- response = HTTPResponse(HTTPRequest('http://tests.python-zeep.org/test.xml'), 200)
- response.buffer = True
- response._body = 'x'
- http_fetch_future = Future()
- http_fetch_future.set_result(response)
- mock_httpclient_fetch.return_value = http_fetch_future
-
- transport = TornadoAsyncTransport(cache=cache)
-
- envelope = etree.Element('Envelope')
-
- result = yield transport.post_xml(
- 'http://tests.python-zeep.org/test.xml',
- envelope=envelope,
- headers={})
-
- assert result.content == 'x'
- assert result.status_code == 200