Projet

Général

Profil

0001-use-zeep-3.2-39119.patch

Thomas Noël, 20 janvier 2020 15:42

Télécharger (4,98 ko)

Voir les différences:

Subject: [PATCH] use zeep 3.2 (#39119)

 debian/control                          |  2 +-
 passerelle/contrib/iparapheur/models.py | 10 ++--------
 setup.py                                |  2 +-
 tests/test_iparapheur.py                |  6 +-----
 tests/test_soap.py                      | 10 ++--------
 tox.ini                                 |  5 ++---
 6 files changed, 9 insertions(+), 26 deletions(-)
debian/control
28 28
    python-dateutil,
29 29
    python-pyproj,
30 30
    python-pil,
31
    python-zeep,
31
    python-zeep (>= 3.2),
32 32
    python-jsonschema,
33 33
    python-unidecode,
34 34
    python-pyexcel-io,
passerelle/contrib/iparapheur/models.py
23 23
from django.utils.translation import ugettext_lazy as _
24 24
from django.http import HttpResponse, Http404
25 25

  
26
from zeep import Settings
26 27
from zeep.exceptions import Fault as WebFault, TransportError, XMLSyntaxError
27
try:
28
    from zeep import Settings  # zeep version >= 3.x
29
except ImportError:
30
    Settings = None
31 28

  
32 29
from passerelle.base.models import BaseResource, HTTPResource
33 30
from passerelle.utils.api import endpoint
......
120 117

  
121 118
    def call(self, service_name, *args, **kwargs):
122 119
        strict_mode = kwargs.pop('strict_mode', True)
123
        if Settings is not None:  # zeep version >= 3.x:
124
            client = self.get_client(settings=Settings(strict=strict_mode))
125
        else:
126
            client = self.get_client(strict=strict_mode)
120
        client = self.get_client(settings=Settings(strict=strict_mode))
127 121
        try:
128 122
            result = getattr(client.overridden_service, service_name)(*args, **kwargs)
129 123
        except WebFault as exc:
setup.py
104 104
            'python-dateutil',
105 105
            'Pillow',
106 106
            'jsonschema < 3.1',
107
            'zeep',
107
            'zeep >= 3.2',
108 108
            'pycrypto',
109 109
            'unidecode',
110 110
            'paramiko',
tests/test_iparapheur.py
8 8
import xml.etree.ElementTree as ET
9 9
from dateutil import parser
10 10
from requests import Response
11
from zeep import __version__ as zeep_version
12 11

  
13 12
from requests.exceptions import ConnectionError
14 13
from django.core.urlresolvers import reverse
......
43 42
    return conn
44 43

  
45 44
def assert_invalid_xml(err_desc):
46
    if zeep_version < '3':
47
        assert "Server returned HTTP status 200 (<nada>)" in err_desc
48
    else:
49
        assert "Server returned response (200) with invalid XML" in err_desc
45
    assert "Server returned response (200) with invalid XML" in err_desc
50 46

  
51 47
def xmlmime():
52 48
    return os.path.join(os.path.dirname(__file__), 'data','xmlmime.xml')
tests/test_soap.py
1 1
import pytest
2 2
import mock
3 3
import requests
4
from zeep import Settings
4 5
from zeep.plugins import Plugin
5 6
from zeep.exceptions import XMLParseError
6
try:
7
    from zeep import Settings  # zeep version >= 3.x
8
except ImportError:
9
    Settings = None
10 7

  
11 8
from passerelle.utils.soap import SOAPClient
12 9

  
......
58 55
            XMLParseError, match="Unexpected element u'price', expected u'skipMe'"):
59 56
        client.service.GetLastTradePrice(tickerSymbol='banana')
60 57

  
61
    if Settings is not None:  # zeep version >= 3.x:
62
        client = SOAPClient(soap_resource, settings=Settings(strict=False))
63
    else:
64
        client = SOAPClient(soap_resource, strict=False)
58
    client = SOAPClient(soap_resource, settings=Settings(strict=False))
65 59
    result = client.service.GetLastTradePrice(tickerSymbol='banana')
66 60
    assert len(result) == 2
67 61
    assert result['skipMe'] == None
tox.ini
1 1
[tox]
2 2
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/passerelle/{env:BRANCH_NAME:}
3
envlist = django111-pg-zeep2
3
envlist = django111-pg
4 4

  
5 5
[testenv]
6 6
usedevelop = True
......
36 36
  vobject
37 37
  django-ratelimit
38 38
  pyquery
39
  zeep2: zeep < 3.0
40
  zeep3: zeep >= 3.0
39
  zeep<3.3
41 40
commands =
42 41
  ./get_wcs.sh
43 42
  django111: py.test {posargs: {env:FAST:} --junitxml=test_{envname}_results.xml --cov-report xml --cov-report html --cov=passerelle/ --cov-config .coveragerc tests/}
44
-