Projet

Général

Profil

0008-misc-fix-import-error-pylint-error-56288.patch

Lauréline Guérin, 30 août 2021 17:53

Télécharger (55,4 ko)

Voir les différences:

Subject: [PATCH 08/31] misc: fix import-error pylint error (#56288)

 combo/apps/lingo/models.py       |  4 +-
 combo/apps/wcs/views.py          |  6 +--
 combo/data/models.py             |  4 +-
 combo/public/views.py            | 11 ++--
 combo/settings.py                |  2 +-
 combo/urls.py                    |  2 +-
 combo/utils/misc.py              |  6 +--
 combo/utils/requests_wrapper.py  | 12 ++---
 combo/utils/signature.py         |  8 +--
 combo/utils/spooler.py           |  4 +-
 combo/wsgi.py                    |  2 +-
 tests/test_calendar.py           |  6 +--
 tests/test_dashboard.py          |  4 +-
 tests/test_lingo_payment.py      | 90 ++++++++++++++++----------------
 tests/test_lingo_remote_regie.py | 42 +++++++--------
 tests/test_manager.py            |  4 +-
 tests/test_public.py             | 50 +++++++++---------
 tests/test_requests.py           | 30 +++++------
 tests/test_wcs.py                |  4 +-
 19 files changed, 145 insertions(+), 146 deletions(-)
combo/apps/lingo/models.py
21 21
import re
22 22
from decimal import Decimal
23 23
from functools import reduce
24
from urllib import parse
24 25

  
25 26
import eopayment
26 27
from dateutil import parser
......
39 40
from django.utils import dateparse, timezone
40 41
from django.utils.encoding import force_bytes, python_2_unicode_compatible
41 42
from django.utils.formats import localize
42
from django.utils.six.moves.urllib import parse as urlparse
43 43
from django.utils.timezone import make_aware, now, utc
44 44
from django.utils.translation import ugettext_lazy as _
45 45
from requests import RequestException
......
557 557
        payment_url = reverse('view-item', kwargs={'regie_id': self.id, 'item_crypto_id': invoice.crypto_id})
558 558
        ctx = settings.TEMPLATE_VARS.copy()
559 559
        ctx['invoice'] = invoice
560
        ctx['payment_url'] = urlparse.urljoin(settings.SITE_BASE_URL, payment_url)
560
        ctx['payment_url'] = parse.urljoin(settings.SITE_BASE_URL, payment_url)
561 561
        ctx['portal_url'] = settings.SITE_BASE_URL
562 562
        subject = render_to_string([subject_template], ctx).strip()
563 563
        text_body = render_to_string([text_body_template], ctx)
combo/apps/wcs/views.py
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import re
18
from urllib import parse
18 19

  
19 20
import ratelimit.utils
20 21
from django.conf import settings
......
22 23
from django.core.exceptions import DisallowedRedirect, PermissionDenied
23 24
from django.http import HttpResponseBadRequest, HttpResponseRedirect, JsonResponse
24 25
from django.utils.http import urlquote
25
from django.utils.six.moves.urllib import parse as urlparse
26 26
from django.utils.translation import ugettext_lazy as _
27 27
from django.views.decorators.csrf import csrf_exempt
28 28
from django.views.generic import View
......
79 79
        code = request.POST['code']
80 80

  
81 81
        next_url = request.POST.get('url') or '/'
82
        next_netloc = urlparse.urlparse(next_url).netloc
82
        next_netloc = parse.urlparse(next_url).netloc
83 83
        redirect_to_other_domain = bool(
84
            next_netloc and next_netloc != urlparse.urlparse(request.build_absolute_uri()).netloc
84
            next_netloc and next_netloc != parse.urlparse(request.build_absolute_uri()).netloc
85 85
        )
86 86

  
87 87
        if redirect_to_other_domain and not is_url_from_known_service(next_url):
combo/data/models.py
24 24
import os
25 25
import re
26 26
import subprocess
27
from urllib import parse
27 28

  
28 29
import feedparser
29 30
import requests
......
51 52
from django.utils.encoding import force_text, python_2_unicode_compatible, smart_bytes
52 53
from django.utils.html import strip_tags
53 54
from django.utils.safestring import mark_safe
54
from django.utils.six.moves.urllib import parse as urlparse
55 55
from django.utils.text import slugify
56 56
from django.utils.timezone import now
57 57
from django.utils.translation import ugettext_lazy as _
......
1432 1432
        else:
1433 1433
            extra_context['title'] = self.title or self.url
1434 1434
        url = self.get_url(context)
1435
        if force_absolute_url and not urlparse.urlparse(url).netloc:
1435
        if force_absolute_url and not parse.urlparse(url).netloc:
1436 1436
            # create full URL when used in a skeleton
1437 1437
            url = request.build_absolute_uri(url)
1438 1438
        extra_context['url'] = url
combo/public/views.py
17 17
import json
18 18
import re
19 19
from itertools import chain
20
from urllib import parse
20 21

  
21 22
from django.conf import settings
22 23
from django.contrib import messages
......
40 41
from django.template.loader import TemplateDoesNotExist, get_template
41 42
from django.utils import lorem_ipsum, timezone
42 43
from django.utils.encoding import force_text
43
from django.utils.six.moves.urllib import parse as urllib
44
from django.utils.six.moves.urllib import parse as urlparse
45 44
from django.utils.translation import ugettext as _
46 45
from django.views.decorators.csrf import csrf_exempt
47 46
from django.views.defaults import page_not_found
......
73 72
            if 'next' not in request.GET:
74 73
                return HttpResponseRedirect(resolve_url('mellon_login'))
75 74
            try:
76
                quoted_next_url = urllib.quote(request.GET.get('next'))
75
                quoted_next_url = parse.quote(request.GET.get('next'))
77 76
            except KeyError:
78 77
                return HttpResponseBadRequest('invalid value for "next" parameter')
79 78
            return HttpResponseRedirect(resolve_url('mellon_login') + '?next=' + quoted_next_url)
......
274 273
        response.status_code = 200
275 274
        return response
276 275

  
277
    parsed_source = urlparse.urlparse(source)
276
    parsed_source = parse.urlparse(source)
278 277
    netloc = parsed_source.netloc
279 278
    if parsed_source.scheme == 'https' and netloc.endswith(':443'):
280 279
        # somme HTTP client (like Mozilla/1.1 (compatible; MSPIE 2.0; Windows
......
300 299
            if selected_page is None or len(redirect_url) >= len(selected_page.get_redirect_url()):
301 300
                selected_page = page
302 301

  
303
        if urlparse.urlparse(redirect_url).netloc == netloc:
302
        if parse.urlparse(redirect_url).netloc == netloc:
304 303
            same_domain_pages.append(page)
305 304

  
306 305
    if selected_page is None and same_domain_pages:
......
313 312
        for service_id in settings.KNOWN_SERVICES or {}:
314 313
            for service_key in settings.KNOWN_SERVICES[service_id]:
315 314
                service = settings.KNOWN_SERVICES[service_id][service_key]
316
                if urlparse.urlparse(service.get('url')).netloc == netloc:
315
                if parse.urlparse(service.get('url')).netloc == netloc:
317 316
                    selected_page = Page()
318 317
                    selected_page.id = '__root'
319 318
                    selected_page.template_name = 'standard'
combo/settings.py
369 369

  
370 370

  
371 371
def debug_show_toolbar(request):
372
    from debug_toolbar.middleware import show_toolbar as dt_show_toolbar
372
    from debug_toolbar.middleware import show_toolbar as dt_show_toolbar  # pylint: disable=import-error
373 373

  
374 374
    return dt_show_toolbar(request) and not request.path.startswith('/__skeleton__/')
375 375

  
combo/urls.py
54 54
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
55 55

  
56 56
if settings.DEBUG and 'debug_toolbar' in settings.INSTALLED_APPS:
57
    import debug_toolbar
57
    import debug_toolbar  # pylint: disable=import-error
58 58

  
59 59
    urlpatterns = [
60 60
        url(r'^__debug__/', include(debug_toolbar.urls)),
combo/utils/misc.py
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import html
18
from urllib import parse
18 19

  
19 20
from django.conf import settings
20 21
from django.template.context import BaseContext
21 22
from django.utils.html import strip_tags
22
from django.utils.six.moves.urllib import parse as urlparse
23 23

  
24 24

  
25 25
def ellipsize(text, length=50):
......
42 42

  
43 43

  
44 44
def is_url_from_known_service(url):
45
    netloc = urlparse.urlparse(url).netloc
45
    netloc = parse.urlparse(url).netloc
46 46
    if not netloc:
47 47
        return True
48 48
    for service_id in settings.KNOWN_SERVICES or {}:
49 49
        for service_key in settings.KNOWN_SERVICES[service_id]:
50 50
            service = settings.KNOWN_SERVICES[service_id][service_key]
51
            if urlparse.urlparse(service.get('url')).netloc == netloc:
51
            if parse.urlparse(service.get('url')).netloc == netloc:
52 52
                return True
53 53
    return False
combo/utils/requests_wrapper.py
16 16

  
17 17
import hashlib
18 18
import logging
19
from urllib import parse
19 20

  
20 21
from django.conf import settings
21 22
from django.core.cache import cache
22 23
from django.utils.encoding import smart_bytes
23 24
from django.utils.http import urlencode
24 25
from django.utils.six import BytesIO
25
from django.utils.six.moves.urllib import parse as urlparse
26 26
from requests import Response
27 27
from requests import Session as RequestsSession
28 28
from requests.auth import AuthBase
......
60 60

  
61 61
        if remote_service == 'auto':
62 62
            remote_service = None
63
            scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
63
            scheme, netloc, path, params, query, fragment = parse.urlparse(url)
64 64
            for services in settings.KNOWN_SERVICES.values():
65 65
                for service in services.values():
66 66
                    remote_url = service.get('url')
67
                    remote_scheme, remote_netloc, dummy, dummy, dummy, dummy = urlparse.urlparse(remote_url)
67
                    remote_scheme, remote_netloc, dummy, dummy, dummy, dummy = parse.urlparse(remote_url)
68 68
                    if remote_scheme == scheme and remote_netloc == netloc:
69 69
                        remote_service = service
70 70
                        break
......
74 74
            if remote_service:
75 75
                # only keeps the path (URI) in url parameter, scheme and netloc are
76 76
                # in remote_service
77
                url = urlparse.urlunparse(('', '', path, params, query, fragment))
77
                url = parse.urlunparse(('', '', path, params, query, fragment))
78 78
            else:
79 79
                logging.warning('service not found in settings.KNOWN_SERVICES for %s', url)
80 80

  
......
103 103
                query_params['orig'] = remote_service.get('orig')
104 104

  
105 105
            remote_service_base_url = remote_service.get('url')
106
            scheme, netloc, dummy, params, old_query, fragment = urlparse.urlparse(remote_service_base_url)
106
            scheme, netloc, dummy, params, old_query, fragment = parse.urlparse(remote_service_base_url)
107 107

  
108 108
            query = urlencode(query_params)
109 109
            if '?' in url:
......
112 112
            else:
113 113
                path = url
114 114

  
115
            url = urlparse.urlunparse((scheme, netloc, path, params, query, fragment))
115
            url = parse.urlunparse((scheme, netloc, path, params, query, fragment))
116 116

  
117 117
        if method == 'GET' and cache_duration:
118 118
            # handle cache
combo/utils/signature.py
19 19
import hashlib
20 20
import hmac
21 21
import random
22
from urllib import parse
22 23

  
23 24
from django.conf import settings
24 25
from django.utils.encoding import smart_bytes
25 26
from django.utils.http import quote, urlencode
26
from django.utils.six.moves.urllib import parse as urlparse
27 27

  
28 28
# Simple signature scheme for query strings
29 29

  
30 30

  
31 31
def sign_url(url, key, algo='sha256', timestamp=None, nonce=None):
32
    parsed = urlparse.urlparse(url)
32
    parsed = parse.urlparse(url)
33 33
    new_query = sign_query(parsed.query, key, algo, timestamp, nonce)
34
    return urlparse.urlunparse(parsed[:4] + (new_query,) + parsed[5:])
34
    return parse.urlunparse(parsed[:4] + (new_query,) + parsed[5:])
35 35

  
36 36

  
37 37
def sign_query(query, key, algo='sha256', timestamp=None, nonce=None):
......
71 71

  
72 72

  
73 73
def check_query(query, keys, known_nonce=None, timedelta=30):
74
    parsed = urlparse.parse_qs(query)
74
    parsed = parse.parse_qs(query)
75 75
    if not ('signature' in parsed and 'algo' in parsed and 'timestamp' in parsed and 'nonce' in parsed):
76 76
        return False
77 77
    unsigned_query, signature_content = query.split('&signature=', 1)
combo/utils/spooler.py
44 44

  
45 45
@contextlib.contextmanager
46 46
def tenant_context(domain):
47
    from hobo.multitenant.middleware import TenantMiddleware
48
    from tenant_schemas.utils import tenant_context
47
    from hobo.multitenant.middleware import TenantMiddleware  # pylint: disable=import-error
48
    from tenant_schemas.utils import tenant_context  # pylint: disable=import-error
49 49

  
50 50
    tenant = TenantMiddleware.get_tenant_by_hostname(domain)
51 51
    with tenant_context(tenant):
combo/wsgi.py
19 19
    # initialize versions as soon as possible as it may be used in most
20 20
    # requests via the statics_hash template var and we prefer not to
21 21
    # load the information during a user request.
22
    from hobo.scrutiny.wsgi.middleware import VersionMiddleware
22
    from hobo.scrutiny.wsgi.middleware import VersionMiddleware  # pylint: disable=import-error
23 23

  
24 24
    VersionMiddleware.get_packages_version()
tests/test_calendar.py
1 1
import datetime
2 2
import json
3 3
from unittest import mock
4
from urllib import parse
4 5

  
5 6
import pytest
6 7
from django.contrib.auth.models import User
7 8
from django.core.cache import cache
8 9
from django.urls import reverse
9
from django.utils.six.moves.urllib import parse as urlparse
10 10

  
11 11
from combo.apps.calendar.models import BookingCalendar
12 12
from combo.apps.calendar.utils import get_calendar, get_chrono_service
......
215 215
    resp.form.set('slots', True, 1)
216 216
    resp.form.set('slots', True, 2)
217 217
    resp = resp.form.submit()
218
    parsed = urlparse.urlparse(resp.url)
218
    parsed = parse.urlparse(resp.url)
219 219
    assert parsed.path == '/test/'
220
    qs = urlparse.parse_qs(parsed.query)
220
    qs = parse.parse_qs(parsed.query)
221 221
    assert qs['session_var_booking_agenda_slug'] == ['test']
222 222
    assert qs['session_var_booking_start'] == ['2017-06-13T08:00:00+00:00']
223 223
    assert qs['session_var_booking_end'] == ['2017-06-13T09:30:00+00:00']
tests/test_dashboard.py
2 2
import json
3 3
import os
4 4
from unittest import mock
5
from urllib import parse
5 6

  
6 7
import pytest
7 8
from django.apps import apps
......
9 10
from django.contrib.auth.models import User
10 11
from django.test import override_settings
11 12
from django.urls import reverse
12
from django.utils.six.moves.urllib import parse as urlparse
13 13

  
14 14
from combo.apps.dashboard.models import DashboardCell, Tile
15 15
from combo.data.models import Page, TextCell
......
50 50
    dashboard = DashboardCell.objects.all()[0]
51 51
    user = User.objects.all()[0]
52 52
    resp = app.get(reverse('combo-dashboard-add-tile', kwargs={'cell_reference': cell.get_reference()}))
53
    assert urlparse.urlparse(resp.location).path == dashboard.page.get_online_url()
53
    assert parse.urlparse(resp.location).path == dashboard.page.get_online_url()
54 54
    assert Tile.objects.count() == 1
55 55
    assert Tile.objects.all()[0].cell.id != cell.id
56 56
    assert Tile.objects.all()[0].cell.text == cell.text
tests/test_lingo_payment.py
4 4
from datetime import datetime, timedelta
5 5
from decimal import Decimal
6 6
from unittest import mock
7
from urllib import parse
7 8

  
8 9
import eopayment
9 10
import httmock
......
16 17
from django.test import override_settings
17 18
from django.urls import reverse
18 19
from django.utils import timezone
19
from django.utils.six.moves.urllib import parse as urlparse
20 20
from django.utils.timezone import now, utc
21 21
from mellon.models import UserSAMLIdentifier
22 22
from requests.exceptions import ConnectionError
......
141 141

  
142 142
    if transaction_id:
143 143
        url, part = url.split('?')
144
        query = urlparse.parse_qs(part)
144
        query = parse.parse_qs(part)
145 145
        assert 'transaction-id' in query
146 146
        assert ':' not in query['transaction-id']
147 147
        assert signing_loads(query['transaction-id'][0]) == transaction_id
......
233 233
    assert resp.status_code == 302
234 234
    location = resp.location
235 235
    assert 'dummy-payment' in location
236
    parsed = urlparse.urlparse(location)
236
    parsed = parse.urlparse(location)
237 237
    # get return_url and transaction id from location
238
    qs = urlparse.parse_qs(parsed.query)
238
    qs = parse.parse_qs(parsed.query)
239 239
    args = {'transaction_id': qs['transaction_id'][0], 'signed': True, 'ok': True, 'reason': 'Paid'}
240 240
    # make sure return url is the user return URL
241
    assert urlparse.urlparse(qs['return_url'][0]).path.startswith(
241
    assert parse.urlparse(qs['return_url'][0]).path.startswith(
242 242
        '/lingo/return-payment-backend/%s/' % regie.payment_backend.id
243 243
    )
244 244
    # simulate successful call to callback URL
......
249 249
    resp = app.get(qs['return_url'][0], params=args)
250 250
    # redirect to payment status
251 251
    assert resp.status_code == 302
252
    assert urlparse.urlparse(resp.url).path.startswith('/lingo/payment-status')
252
    assert parse.urlparse(resp.url).path.startswith('/lingo/payment-status')
253 253
    resp = resp.follow()
254 254
    assert 'Your payment has been succesfully registered.' in resp.text
255
    assert urlparse.urlparse(resp.html.find('a', {'id': 'next-url'})['href']).path == '/test_basket_cell/'
255
    assert parse.urlparse(resp.html.find('a', {'id': 'next-url'})['href']).path == '/test_basket_cell/'
256 256

  
257 257

  
258 258
def test_add_amount_to_basket(app, key, regie, user_name_id):
......
346 346
    assert resp.status_code == 200
347 347
    response = json.loads(resp.text)
348 348
    assert response['result'] == 'success'
349
    payment_url = urlparse.urlparse(response['payment_url'])
349
    payment_url = parse.urlparse(response['payment_url'])
350 350
    assert payment_url.path.startswith('/lingo/item/')
351 351
    assert payment_url.path.endswith('/pay')
352 352
    assert BasketItem.objects.filter(amount=Decimal('22.23')).exists()
......
395 395
    monkeypatch.setattr(eopayment.Payment, 'request', eopayment_mock)
396 396
    resp = resp.form.submit()
397 397
    assert resp.status_code == 302
398
    location = urlparse.urlparse(resp.location)
398
    location = parse.urlparse(resp.location)
399 399
    assert location.path == '/'
400 400
    assert location.hostname == 'dummy-payment.demo.entrouvert.com'
401 401

  
......
527 527
    resp = login(app).get('/test_basket_cell/')
528 528
    resp = resp.form.submit()
529 529
    assert resp.status_code == 302
530
    assert urlparse.urlparse(resp.location).path == '/test_basket_cell/'
530
    assert parse.urlparse(resp.location).path == '/test_basket_cell/'
531 531
    resp = resp.follow()
532 532
    assert "Invalid grouping for basket items: different capture dates." in resp.text
533 533

  
......
572 572

  
573 573
    # make sure the redirection is done to the payment backend
574 574
    assert resp.location.startswith('http://dummy-payment.demo.entrouvert.com/')
575
    qs = urlparse.parse_qs(urlparse.urlparse(resp.location).query)
575
    qs = parse.parse_qs(parse.urlparse(resp.location).query)
576 576
    assert qs['amount'] == ['12.00']
577 577
    # simulate successful payment response from dummy backend
578 578
    data = {'transaction_id': qs['transaction_id'][0], 'ok': True, 'amount': qs['amount'][0], 'signed': True}
......
610 610

  
611 611
    # make sure the redirection is done to the payment backend
612 612
    assert resp.location.startswith('http://dummy-payment.demo.entrouvert.com/')
613
    qs = urlparse.parse_qs(urlparse.urlparse(resp.location).query)
613
    qs = parse.parse_qs(parse.urlparse(resp.location).query)
614 614
    assert qs['amount'] == ['12.00']
615 615
    # simulate successful payment response from dummy backend
616 616
    data = {'transaction_id': qs['transaction_id'][0], 'ok': True, 'amount': qs['amount'][0], 'signed': True}
......
635 635
    resp = login(app).get(page.get_online_url())
636 636
    resp = resp.forms[0].submit()
637 637
    assert resp.location.startswith('http://dummy-payment.demo.entrouvert.com/')
638
    qs = urlparse.parse_qs(urlparse.urlparse(resp.location).query)
638
    qs = parse.parse_qs(parse.urlparse(resp.location).query)
639 639
    assert qs['amount'] == ['234.46']
640 640

  
641 641
    resp = login(app).get(page.get_online_url())
642 642
    resp = resp.forms[1].submit()
643
    qs = urlparse.parse_qs(urlparse.urlparse(resp.location).query)
643
    qs = parse.parse_qs(parse.urlparse(resp.location).query)
644 644
    assert qs['amount'] == ['22.23']
645 645

  
646 646

  
......
816 816
    resp = resp.form.submit()
817 817
    assert resp.status_code == 302
818 818
    location = resp.location
819
    parsed = urlparse.urlparse(location)
820
    qs = urlparse.parse_qs(parsed.query)
819
    parsed = parse.urlparse(location)
820
    qs = parse.parse_qs(parsed.query)
821 821
    transaction_id = qs['transaction_id'][0]
822 822
    data = {'transaction_id': transaction_id, 'signed': True, 'amount': qs['amount'][0], 'ok': True}
823 823
    assert data['amount'] == '10.50'
......
838 838
    resp = resp.form.submit()
839 839
    assert resp.status_code == 302
840 840
    location = resp.location
841
    parsed = urlparse.urlparse(location)
842
    qs = urlparse.parse_qs(parsed.query)
841
    parsed = parse.urlparse(location)
842
    qs = parse.parse_qs(parsed.query)
843 843
    transaction_id = qs['transaction_id'][0]
844 844
    return_url = qs['return_url'][0]
845 845
    data = {'transaction_id': transaction_id, 'signed': True, 'amount': qs['amount'][0], 'ok': True}
......
867 867
    resp = resp.form.submit()
868 868
    assert resp.status_code == 302
869 869
    location = resp.location
870
    parsed = urlparse.urlparse(location)
871
    qs = urlparse.parse_qs(parsed.query)
870
    parsed = parse.urlparse(location)
871
    qs = parse.parse_qs(parsed.query)
872 872
    transaction_id = qs['transaction_id'][0]
873 873
    data = {'transaction_id': transaction_id, 'signed': True, 'amount': qs['amount'][0], 'ok': True}
874 874
    assert data['amount'] == '10.50'
......
889 889
    resp = resp.form.submit()
890 890
    assert resp.status_code == 302
891 891
    location = resp.location
892
    parsed = urlparse.urlparse(location)
893
    qs = urlparse.parse_qs(parsed.query)
892
    parsed = parse.urlparse(location)
893
    qs = parse.parse_qs(parsed.query)
894 894
    transaction_id = qs['transaction_id'][0]
895 895
    data = {'transaction_id': transaction_id, 'signed': True, 'amount': qs['amount'][0], 'ok': True}
896 896
    assert data['amount'] == '11.50'
......
907 907
    resp = resp.form.submit()
908 908
    assert resp.status_code == 302
909 909
    location = resp.location
910
    parsed = urlparse.urlparse(location)
911
    qs = urlparse.parse_qs(parsed.query)
910
    parsed = parse.urlparse(location)
911
    qs = parse.parse_qs(parsed.query)
912 912
    return_url = qs['return_url'][0]
913 913
    transaction_id = qs['transaction_id'][0]
914 914
    data = {'transaction_id': transaction_id, 'signed': True, 'amount': qs['amount'][0], 'ok': True}
......
957 957
    resp = resp.form.submit()
958 958
    assert resp.status_code == 302
959 959
    location = resp.location
960
    parsed = urlparse.urlparse(location)
961
    qs = urlparse.parse_qs(parsed.query)
960
    parsed = parse.urlparse(location)
961
    qs = parse.parse_qs(parsed.query)
962 962
    transaction_id = qs['transaction_id'][0]
963 963
    data = {'transaction_id': transaction_id, 'signed': True, 'amount': qs['amount'][0], 'waiting': True}
964 964
    assert data['amount'] == '10.50'
......
994 994
    resp = resp.form.submit()
995 995
    assert resp.status_code == 302
996 996
    location = resp.location
997
    parsed = urlparse.urlparse(location)
998
    qs = urlparse.parse_qs(parsed.query)
997
    parsed = parse.urlparse(location)
998
    qs = parse.parse_qs(parsed.query)
999 999
    transaction_id = qs['transaction_id'][0]
1000 1000
    data = {'transaction_id': transaction_id, 'amount': qs['amount'][0], 'ok': True}
1001 1001
    assert data['amount'] == '10.50'
......
1007 1007
            get_resp = app.post(return_url, params=data)
1008 1008
            assert request.call_count == 0
1009 1009
        assert get_resp.status_code == 302
1010
        assert urlparse.urlparse(get_resp['location']).path == '/lingo/payment-status'
1010
        assert parse.urlparse(get_resp['location']).path == '/lingo/payment-status'
1011 1011
        assert Transaction.objects.get(order_id=transaction_id).status == 0  # not paid
1012 1012

  
1013 1013
    # call return with missing data
......
1030 1030
        assert url.startswith('http://example.org/testitem/jump/trigger/paid')
1031 1031
    # redirect to payment status
1032 1032
    assert get_resp.status_code == 302
1033
    assert urlparse.urlparse(get_resp.url).path.startswith('/lingo/payment-status')
1033
    assert parse.urlparse(get_resp.url).path.startswith('/lingo/payment-status')
1034 1034
    resp = get_resp.follow()
1035 1035
    assert 'Your payment has been succesfully registered.' in resp.text
1036
    assert urlparse.urlparse(resp.html.find('a', {'id': 'next-url'})['href']).path == '/test_basket_cell/'
1036
    assert parse.urlparse(resp.html.find('a', {'id': 'next-url'})['href']).path == '/test_basket_cell/'
1037 1037
    assert Transaction.objects.get(order_id=transaction_id).status == eopayment.PAID
1038 1038

  
1039 1039

  
......
1353 1353
        resp = resp.form.submit()
1354 1354
    assert resp.status_code == 302
1355 1355
    location = resp.location
1356
    parsed = urlparse.urlparse(location)
1357
    qs = urlparse.parse_qs(parsed.query)
1356
    parsed = parse.urlparse(location)
1357
    qs = parse.parse_qs(parsed.query)
1358 1358
    transaction_id = qs['transaction_id'][0]
1359 1359
    data = {'transaction_id': transaction_id, 'signed': True, 'amount': qs['amount'][0], 'ok': True}
1360 1360
    assert data['amount'] == '44.00'
......
1369 1369
        resp = resp.form.submit()
1370 1370
    assert resp.status_code == 302
1371 1371
    location = resp.location
1372
    parsed = urlparse.urlparse(location)
1373
    qs = urlparse.parse_qs(parsed.query)
1372
    parsed = parse.urlparse(location)
1373
    qs = parse.parse_qs(parsed.query)
1374 1374
    transaction_id = qs['transaction_id'][0]
1375 1375
    data = {'transaction_id': transaction_id, 'signed': True, 'amount': qs['amount'][0], 'ok': True}
1376 1376
    assert data['amount'] == '45.00'
......
1391 1391
    resp = resp.form.submit()
1392 1392
    assert resp.status_code == 302
1393 1393
    location = resp.location
1394
    parsed = urlparse.urlparse(location)
1395
    qs = urlparse.parse_qs(parsed.query)
1394
    parsed = parse.urlparse(location)
1395
    qs = parse.parse_qs(parsed.query)
1396 1396
    transaction_id = qs['transaction_id'][0]
1397 1397
    data = {'transaction_id': transaction_id, 'signed': True, 'amount': qs['amount'][0], 'ok': True}
1398 1398
    assert data['amount'] == '10.50'
......
1463 1463
    item = BasketItem.objects.first()
1464 1464
    assert item.user is None
1465 1465
    assert item.amount == Decimal('10.00')
1466
    path = urlparse.urlparse(payment_url).path
1466
    path = parse.urlparse(payment_url).path
1467 1467
    start = '/lingo/item/'
1468 1468
    end = '/pay'
1469 1469
    assert path.startswith(start)
......
1489 1489
    item.save()
1490 1490
    resp = app.get(payment_url)
1491 1491
    assert resp.location.startswith('http://dummy-payment.demo.entrouvert.com/')
1492
    qs = urlparse.parse_qs(urlparse.urlparse(resp.location).query)
1492
    qs = parse.parse_qs(parse.urlparse(resp.location).query)
1493 1493
    assert qs['amount'] == ['10.00']
1494 1494
    if authenticated:
1495 1495
        assert qs['email'] == ['foo@example.com']
......
1504 1504
        },
1505 1505
    )
1506 1506
    assert resp.location.startswith('http://dummy-payment.demo.entrouvert.com/')
1507
    qs = urlparse.parse_qs(urlparse.urlparse(resp.location).query)
1507
    qs = parse.parse_qs(parse.urlparse(resp.location).query)
1508 1508
    assert qs['amount'] == ['10.00']
1509 1509
    if authenticated:
1510 1510
        assert qs['email'] == ['foo@example.com']
......
1644 1644

  
1645 1645
    # make sure the redirection is done to the payment backend
1646 1646
    assert resp.location.startswith('http://dummy-payment.demo.entrouvert.com/')
1647
    qs = urlparse.parse_qs(urlparse.urlparse(resp.location).query)
1647
    qs = parse.parse_qs(parse.urlparse(resp.location).query)
1648 1648
    assert qs['amount'] == ['12.00']
1649 1649
    # simulate successful payment response from dummy backend
1650 1650
    transaction_id = (qs['transaction_id'][0],)
......
1722 1722
    resp = resp.click('Pay', href=item.payment_url)
1723 1723

  
1724 1724
    # successful payment
1725
    qs = urlparse.parse_qs(urlparse.urlparse(resp.location).query)
1725
    qs = parse.parse_qs(parse.urlparse(resp.location).query)
1726 1726
    assert qs['subject'][0] == 'foo item', 'item.subject was not provided to eopayment'
1727 1727
    assert qs['orderid'][0] == 'form-3-23'
1728 1728
    args = {'transaction_id': qs['transaction_id'][0], 'signed': True, 'ok': True, 'reason': 'Paid'}
......
1744 1744
    )
1745 1745

  
1746 1746
    resp = login(app).get(item.payment_url)
1747
    qs = urlparse.parse_qs(urlparse.urlparse(resp.location).query)
1747
    qs = parse.parse_qs(parse.urlparse(resp.location).query)
1748 1748
    assert qs['subject'][0] == 'foo item', 'item.subject was not provided to eopayment'
1749 1749
    assert qs['info3'][0] == 'très fragile'
1750 1750

  
......
1789 1789
    mono_regie.payment_backend.save()
1790 1790

  
1791 1791
    resp = login(app).get(item.payment_url)
1792
    qs = urlparse.parse_qs(urlparse.urlparse(resp.location).query)
1792
    qs = parse.parse_qs(parse.urlparse(resp.location).query)
1793 1793
    assert qs['refdet'][0] == 'F20201030'
1794 1794
    assert qs['exer'][0] == '2020'
1795 1795

  
......
1836 1836

  
1837 1837
def test_email_from_basket(app, regie, remote_invoices_httmock):
1838 1838
    def parse_qs(url):
1839
        return QueryDict(urlparse.urlparse(url).query)
1839
        return QueryDict(parse.urlparse(url).query)
1840 1840

  
1841 1841
    user1 = User.objects.create(username='user1', email='user1@example.com')
1842 1842
    user2 = User.objects.create(username='user2', email='user2@example.com')
tests/test_lingo_remote_regie.py
2 2
import json
3 3
from decimal import Decimal
4 4
from unittest import mock
5
from urllib import parse
5 6

  
6 7
import eopayment
7 8
import httmock
......
14 15
from django.test.client import RequestFactory
15 16
from django.urls import reverse
16 17
from django.utils.encoding import force_bytes, force_text
17
from django.utils.six.moves.urllib import parse as urlparse
18 18
from django.utils.timezone import now, timedelta
19 19
from requests.exceptions import ConnectionError
20 20
from requests.models import Response
......
156 156
    # check if regie webservice has been correctly called
157 157
    assert mock_send.call_args[0][0].method == 'GET'
158 158
    url = mock_send.call_args[0][0].url
159
    scheme, netloc, path, dummy, querystring, dummy = urlparse.urlparse(url)
159
    scheme, netloc, path, dummy, querystring, dummy = parse.urlparse(url)
160 160
    assert scheme == 'http'
161 161
    assert netloc == 'example.org'
162 162
    assert path == '/regie/invoices/'
163
    query = urlparse.parse_qs(querystring, keep_blank_values=True)
163
    query = parse.parse_qs(querystring, keep_blank_values=True)
164 164
    assert query['NameID'][0] == 'r2d2'
165 165
    assert query['orig'][0] == 'combo'
166 166
    assert check_query(querystring, 'combo') is True
......
285 285
    # check if regie webservice has been correctly called
286 286
    assert mock_send.call_args[0][0].method == 'GET'
287 287
    url = mock_send.call_args[0][0].url
288
    scheme, netloc, path, dummy, querystring, dummy = urlparse.urlparse(url)
288
    scheme, netloc, path, dummy, querystring, dummy = parse.urlparse(url)
289 289
    assert scheme == 'http'
290 290
    assert netloc == 'example.org'
291 291
    assert path == '/regie/invoices/history/'
292
    query = urlparse.parse_qs(querystring, keep_blank_values=True)
292
    query = parse.parse_qs(querystring, keep_blank_values=True)
293 293
    assert query['NameID'][0] == 'r2d2'
294 294
    assert query['orig'][0] == 'combo'
295 295
    assert check_query(querystring, 'combo') is True
......
408 408
    assert resp.status_code == 302
409 409
    location = resp.location
410 410
    assert 'dummy-payment' in location
411
    parsed = urlparse.urlparse(location)
411
    parsed = parse.urlparse(location)
412 412
    # get return_url and transaction id from location
413
    qs = urlparse.parse_qs(parsed.query)
413
    qs = parse.parse_qs(parsed.query)
414 414
    args = {'transaction_id': qs['transaction_id'][0], 'signed': True, 'ok': True, 'reason': 'Paid'}
415 415
    # make sure return url is the user return URL
416 416
    return_url = qs['return_url'][0]
417
    assert urlparse.urlparse(return_url).path.startswith('/lingo/return-payment-backend')
417
    assert parse.urlparse(return_url).path.startswith('/lingo/return-payment-backend')
418 418
    # simulate successful return URL
419 419
    resp = app.get(qs['return_url'][0], params=args)
420 420
    # redirect to payment status
421 421
    assert resp.status_code == 302
422
    assert urlparse.urlparse(resp.url).path.startswith('/lingo/payment-status')
422
    assert parse.urlparse(resp.url).path.startswith('/lingo/payment-status')
423 423
    resp = resp.follow()
424
    assert urlparse.urlparse(resp.html.find('a', {'id': 'next-url'})['href']).path == '/'
424
    assert parse.urlparse(resp.html.find('a', {'id': 'next-url'})['href']).path == '/'
425 425
    # simulate successful call to callback URL
426 426
    resp = app.get(reverse('lingo-callback', kwargs={'regie_pk': remote_regie.id}), params=args)
427 427
    trans = Transaction.objects.all()
......
520 520
    resp = form.submit()
521 521

  
522 522
    assert resp.status_code == 302
523
    path = urlparse.urlparse(resp.location).path
523
    path = parse.urlparse(resp.location).path
524 524
    assert path == '/lingo/item/%s/%s/' % (remote_regie.id, encrypt_id)
525 525

  
526 526

  
......
570 570
    resp.form['invoice-number'] = 'F201601'
571 571
    resp.form['invoice-amount'] = '123.45'
572 572
    resp = resp.form.submit()
573
    path = urlparse.urlparse(resp.location).path
573
    path = parse.urlparse(resp.location).path
574 574
    assert path.startswith('/lingo/item/%s/' % remote_regie.id)
575 575
    resp = resp.follow()
576 576

  
......
605 605
    assert resp.status_code == 302
606 606
    location = resp.location
607 607
    assert 'dummy-payment' in location
608
    parsed = urlparse.urlparse(location)
608
    parsed = parse.urlparse(location)
609 609
    # get return_url and transaction id from location
610
    qs = urlparse.parse_qs(parsed.query)
610
    qs = parse.parse_qs(parsed.query)
611 611
    args = {'transaction_id': qs['transaction_id'][0], 'signed': True, 'ok': True, 'reason': 'Paid'}
612 612
    # make sure return url is the user return URL
613 613
    return_url = qs['return_url'][0]
614
    assert urlparse.urlparse(return_url).path.startswith(
614
    assert parse.urlparse(return_url).path.startswith(
615 615
        '/lingo/return-payment-backend/%s/' % remote_regie.payment_backend.id
616 616
    )
617 617
    # simulate payment failure
......
619 619
    resp = app.get(qs['return_url'][0], params=args)
620 620
    # redirect to payment status
621 621
    assert resp.status_code == 302
622
    assert urlparse.urlparse(resp.url).path.startswith('/lingo/payment-status')
622
    assert parse.urlparse(resp.url).path.startswith('/lingo/payment-status')
623 623
    resp = resp.follow()
624 624
    assert (
625
        urlparse.urlparse(resp.html.find('a', {'id': 'next-url'})['href']).path
625
        parse.urlparse(resp.html.find('a', {'id': 'next-url'})['href']).path
626 626
        == '/active-remote-invoices-page/'
627 627
    )
628 628

  
......
674 674
    assert resp.status_code == 302
675 675
    location = resp.location
676 676
    assert 'dummy-payment' in location
677
    parsed = urlparse.urlparse(location)
677
    parsed = parse.urlparse(location)
678 678
    # get return_url and transaction id from location
679
    qs = urlparse.parse_qs(parsed.query)
679
    qs = parse.parse_qs(parsed.query)
680 680
    if can_pay_only_one_basket_item:
681 681
        assert qs['orderid'] == ['order-id-1']
682 682
        assert qs['subject'] == ['invoice-one']
......
687 687
    resp = app.get(qs['return_url'][0], params=args)
688 688
    # redirect to payment status
689 689
    assert resp.status_code == 302
690
    assert urlparse.urlparse(resp.url).path.startswith('/lingo/payment-status')
690
    assert parse.urlparse(resp.url).path.startswith('/lingo/payment-status')
691 691
    resp = resp.follow()
692 692
    assert (
693
        urlparse.urlparse(resp.html.find('a', {'id': 'next-url'})['href']).path
693
        parse.urlparse(resp.html.find('a', {'id': 'next-url'})['href']).path
694 694
        == '/active-remote-invoices-page/'
695 695
    )
696 696

  
tests/test_manager.py
5 5
import re
6 6
import shutil
7 7
from unittest import mock
8
from urllib import parse
8 9

  
9 10
import pytest
10 11
from django.conf import settings
......
21 22
from django.utils.encoding import force_bytes, force_str
22 23
from django.utils.http import urlencode
23 24
from django.utils.six import BytesIO
24
from django.utils.six.moves.urllib import parse as urlparse
25 25
from django.utils.timezone import now
26 26
from webtest import Upload
27 27

  
......
2369 2369
    assert '/admin/logout/' in resp.text
2370 2370
    resp = resp.click(href='/admin/logout/')
2371 2371
    resp = resp.follow()  # -> /logout/
2372
    assert urlparse.urlparse(resp.location).path == '/'
2372
    assert parse.urlparse(resp.location).path == '/'
2373 2373

  
2374 2374

  
2375 2375
def test_json_cell_syntax_validation(app, admin_user):
tests/test_public.py
3 3
import os
4 4
import re
5 5
from unittest import mock
6
from urllib import parse
6 7

  
7 8
import pytest
8 9
from django.conf import settings
......
14 15
from django.urls import reverse
15 16
from django.utils.http import quote
16 17
from django.utils.six import StringIO
17
from django.utils.six.moves.urllib import parse as urlparse
18 18

  
19 19
try:
20 20
    import mellon  # pylint: disable=unused-import
......
52 52
    page = Page(title='Home', slug='index', template_name='standard')
53 53
    page.save()
54 54
    resp = app.get('/index', status=301)
55
    assert urlparse.urlparse(resp.location).path == '/'
55
    assert parse.urlparse(resp.location).path == '/'
56 56
    resp = app.get('/', status=200)
57 57

  
58 58
    # check {% now %} inside a skeleton_extra_placeholder is interpreted
......
88 88
    with mock.patch('combo.public.views.get_idps') as get_idps:
89 89
        get_idps.return_value = ['xxx']
90 90
        resp = app.get('/login/')
91
        assert urlparse.urlparse(resp.location).path == '/accounts/mellon/login/'
91
        assert parse.urlparse(resp.location).path == '/accounts/mellon/login/'
92 92
        resp = app.get('/login/?next=whatever')
93
        assert urlparse.urlparse(resp.location).query == 'next=whatever'
93
        assert parse.urlparse(resp.location).query == 'next=whatever'
94 94

  
95 95

  
96 96
def test_page_contents_group_presence(app, normal_user):
......
158 158
    ParentContentCell(page=page, placeholder='footer', order=0).save()
159 159
    TextCell(page=page, placeholder='footer', text='BAR2FOO', order=1).save()
160 160
    resp = app.get('/second', status=301)
161
    assert urlparse.urlparse(resp.location).path == '/second/'
161
    assert parse.urlparse(resp.location).path == '/second/'
162 162
    with CaptureQueriesContext(connection) as ctx:
163 163
        resp = app.get('/second/', status=200)
164 164
        assert resp.text.count('BARFOO') == 1
......
447 447
    assert 'Grand child of home' in resp.text
448 448

  
449 449
    assert (
450
        urlparse.urlparse(app.get('/child-home/grand-child-home', status=301).location).path
450
        parse.urlparse(app.get('/child-home/grand-child-home', status=301).location).path
451 451
        == '/child-home/grand-child-home/'
452 452
    )
453 453
    app.get('/grand-child-home/', status=404)
......
653 653
        # first visit
654 654
        app = login(app)
655 655
        resp = app.get('/', status=302)
656
        assert urlparse.urlparse(resp.location).path == '/initial-login/'
656
        assert parse.urlparse(resp.location).path == '/initial-login/'
657 657

  
658 658
        # visit again
659 659
        resp = app.get('/', status=200)
......
669 669
    with override_settings(COMBO_WELCOME_PAGE_PATH='/welcome/'):
670 670
        app.cookiejar.clear()
671 671
        resp = app.get('/', status=302)
672
        assert urlparse.urlparse(resp.location).path == '/welcome/'
672
        assert parse.urlparse(resp.location).path == '/welcome/'
673 673

  
674 674
        resp = app.get('/', status=200)
675 675

  
676 676
        app.cookiejar.clear()
677 677
        resp = app.get('/', status=302)
678
        assert urlparse.urlparse(resp.location).path == '/welcome/'
678
        assert parse.urlparse(resp.location).path == '/welcome/'
679 679

  
680 680
        app.cookiejar.clear()
681 681
        app = login(app)
......
749 749
                assert requests_post.call_args[0][0] == 'POST'
750 750
                assert requests_post.call_args[0][1] == 'http://test-post-cell/slug/create/'
751 751
                assert requests_post.call_args[1]['json'] == {'value': 'plop', 'items': ['1']}
752
                assert urlparse.urlparse(resp2.location).path == '/'
752
                assert parse.urlparse(resp2.location).path == '/'
753 753

  
754 754
            # check ajax call
755 755
            with mock.patch('combo.utils.requests.request') as requests_post:
......
764 764
            with mock.patch('combo.utils.requests.request') as requests_post:
765 765
                requests_post.return_value = mock.Mock(content=json.dumps({'err': 0}), status_code=400)
766 766
                resp2 = resp.form.submit()
767
                assert urlparse.urlparse(resp2.location).path == '/'
767
                assert parse.urlparse(resp2.location).path == '/'
768 768
                resp2 = resp2.follow()
769 769
                assert 'Error sending data.' in resp2.text
770 770

  
......
772 772
                    'error-message'
773 773
                ] = 'Failed to create stuff.'
774 774
                resp2 = resp.form.submit()
775
                assert urlparse.urlparse(resp2.location).path == '/'
775
                assert parse.urlparse(resp2.location).path == '/'
776 776
                resp2 = resp2.follow()
777 777
                assert 'Failed to create stuff.' in resp2.text
778 778

  
......
799 799
                assert requests_patch.call_args[0][0] == 'PATCH'
800 800
                assert requests_patch.call_args[0][1] == 'http://test-post-cell/slug/update/'
801 801
                assert requests_patch.call_args[1]['json'] == {'value': 'plop', 'items': ['1']}
802
                assert urlparse.urlparse(resp2.location).path == '/'
802
                assert parse.urlparse(resp2.location).path == '/'
803 803

  
804 804
            # check raw result
805 805
            with mock.patch('combo.utils.requests.request') as requests_search:
......
1016 1016
    redirect = Redirect(old_url='/whatever/', page=page3)
1017 1017
    redirect.save()
1018 1018

  
1019
    assert urlparse.urlparse(app.get('/whatever/', status=302).location).path == '/second/third/'
1020
    assert urlparse.urlparse(app.get('/whatever', status=301).location).path == '/whatever/'
1019
    assert parse.urlparse(app.get('/whatever/', status=302).location).path == '/second/third/'
1020
    assert parse.urlparse(app.get('/whatever', status=301).location).path == '/whatever/'
1021 1021

  
1022 1022
    # check the most recent redirect is called
1023 1023
    redirect = Redirect(old_url='/whatever/', page=page2)
1024 1024
    redirect.save()
1025
    assert urlparse.urlparse(app.get('/whatever/', status=302).location).path == '/second/'
1025
    assert parse.urlparse(app.get('/whatever/', status=302).location).path == '/second/'
1026 1026

  
1027 1027
    # rename page
1028 1028
    page3.slug = 'third2'
1029 1029
    page3.save()
1030 1030
    assert app.get('/second/third2/', status=200)
1031
    assert urlparse.urlparse(app.get('/second/third/', status=302).location).path == '/second/third2/'
1031
    assert parse.urlparse(app.get('/second/third/', status=302).location).path == '/second/third2/'
1032 1032

  
1033 1033
    page2.slug = 'second2'
1034 1034
    page2.save()
1035
    assert urlparse.urlparse(app.get('/second/third/', status=302).location).path == '/second2/third2/'
1036
    assert urlparse.urlparse(app.get('/second/third2/', status=302).location).path == '/second2/third2/'
1037
    assert urlparse.urlparse(app.get('/second/', status=302).location).path == '/second2/'
1035
    assert parse.urlparse(app.get('/second/third/', status=302).location).path == '/second2/third2/'
1036
    assert parse.urlparse(app.get('/second/third2/', status=302).location).path == '/second2/third2/'
1037
    assert parse.urlparse(app.get('/second/', status=302).location).path == '/second2/'
1038 1038

  
1039 1039
    # change parent
1040 1040
    page3.parent = None
1041 1041
    page3.save()
1042
    assert urlparse.urlparse(app.get('/second/third/', status=302).location).path == '/third2/'
1043
    assert urlparse.urlparse(app.get('/second2/third2/', status=302).location).path == '/third2/'
1042
    assert parse.urlparse(app.get('/second/third/', status=302).location).path == '/third2/'
1043
    assert parse.urlparse(app.get('/second2/third2/', status=302).location).path == '/third2/'
1044 1044

  
1045 1045

  
1046 1046
def test_sub_slug(app, john_doe, jane_doe):
......
1158 1158

  
1159 1159
def test_missing_trailing_slashes(app):
1160 1160
    # redirect to path with slash
1161
    assert urlparse.urlparse(app.get('/login', status=301).location).path == '/login/'
1162
    assert urlparse.urlparse(app.get('/foo', status=301).location).path == '/foo/'
1161
    assert parse.urlparse(app.get('/login', status=301).location).path == '/login/'
1162
    assert parse.urlparse(app.get('/foo', status=301).location).path == '/foo/'
1163 1163
    # don't be tricked by double slashes
1164
    assert urlparse.urlparse(app.get('//foo', status=301).location).path == '/foo/'
1164
    assert parse.urlparse(app.get('//foo', status=301).location).path == '/foo/'
1165 1165

  
1166 1166

  
1167 1167
def test_cell_asset_css_classes(settings, app, admin_user):
tests/test_requests.py
1 1
from unittest import mock
2
from urllib import parse
2 3

  
3 4
import pytest
4 5
from django.contrib.auth.models import AnonymousUser
5
from django.utils.six.moves.urllib import parse as urlparse
6 6

  
7 7
from combo.utils import NothingInCacheException, check_query, requests
8 8

  
......
32 32
        requests.get('/foo/bar/', remote_service=remote_service)
33 33
        url = send.call_args[0][0].url
34 34
        assert url.startswith('http://example.org/foo/bar/?')
35
        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
36
        query = urlparse.parse_qs(querystring, keep_blank_values=True)
35
        dummy, dummy, dummy, dummy, querystring, dummy = parse.urlparse(url)
36
        query = parse.parse_qs(querystring, keep_blank_values=True)
37 37
        assert query['orig'][0] == 'myself'
38 38
        assert query['email'][0] == ''
39 39
        assert query['NameID'][0] == ''
......
42 42
        requests.get('/foo/bar/', remote_service=remote_service, without_user=True)
43 43
        url = send.call_args[0][0].url
44 44
        assert url.startswith('http://example.org/foo/bar/?')
45
        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
46
        query = urlparse.parse_qs(querystring, keep_blank_values=True)
45
        dummy, dummy, dummy, dummy, querystring, dummy = parse.urlparse(url)
46
        query = parse.parse_qs(querystring, keep_blank_values=True)
47 47
        assert query['orig'][0] == 'myself'
48 48
        assert 'email' not in query
49 49
        assert 'NameID' not in query
......
55 55
        requests.get('http://example.org/foo/bar/', remote_service='auto')
56 56
        url = send.call_args[0][0].url
57 57
        assert url.startswith('http://example.org/foo/bar/?')
58
        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
59
        query = urlparse.parse_qs(querystring, keep_blank_values=True)
58
        dummy, dummy, dummy, dummy, querystring, dummy = parse.urlparse(url)
59
        query = parse.parse_qs(querystring, keep_blank_values=True)
60 60
        assert query['orig'][0] == 'combo'
61 61
        assert check_query(querystring, 'combo') is True
62 62

  
......
73 73
        requests.get('/foo/bar/', remote_service=remote_service, user=user)
74 74
        url = send.call_args[0][0].url
75 75
        assert url.startswith('http://example.org/foo/bar/?')
76
        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
77
        query = urlparse.parse_qs(querystring, keep_blank_values=True)
76
        dummy, dummy, dummy, dummy, querystring, dummy = parse.urlparse(url)
77
        query = parse.parse_qs(querystring, keep_blank_values=True)
78 78
        assert query['NameID'][0] == 'r2d2'
79 79
        assert 'email' not in query
80 80
        assert query['orig'][0] == 'myself'
......
83 83
        requests.get('/foo/bar/', remote_service=remote_service, user=user, federation_key='email')
84 84
        url = send.call_args[0][0].url
85 85
        assert url.startswith('http://example.org/foo/bar/?')
86
        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
87
        query = urlparse.parse_qs(querystring, keep_blank_values=True)
86
        dummy, dummy, dummy, dummy, querystring, dummy = parse.urlparse(url)
87
        query = parse.parse_qs(querystring, keep_blank_values=True)
88 88
        assert query['email'][0] == 'foo@example.net'
89 89
        assert 'NameID' not in query
90 90
        assert query['orig'][0] == 'myself'
......
95 95
        requests.get('/foo/bar/', remote_service=remote_service, user=user)
96 96
        url = send.call_args[0][0].url
97 97
        assert url.startswith('http://example.org/foo/bar/?')
98
        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
99
        query = urlparse.parse_qs(querystring, keep_blank_values=True)
98
        dummy, dummy, dummy, dummy, querystring, dummy = parse.urlparse(url)
99
        query = parse.parse_qs(querystring, keep_blank_values=True)
100 100
        assert 'NameID' not in query
101 101
        assert query['email'][0] == 'foo@example.net'
102 102
        assert query['orig'][0] == 'myself'
......
112 112
        requests.get('/foo/bar/', remote_service=remote_service, user=user)
113 113
        url = send.call_args[0][0].url
114 114
        assert url.startswith('http://example.org/foo/bar/?')
115
        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
116
        query = urlparse.parse_qs(querystring, keep_blank_values=True)
115
        dummy, dummy, dummy, dummy, querystring, dummy = parse.urlparse(url)
116
        query = parse.parse_qs(querystring, keep_blank_values=True)
117 117
        assert query['NameID'][0] == ''
118 118
        assert query['email'][0] == ''
119 119
        assert query['orig'][0] == 'myself'
tests/test_wcs.py
2 2
import json
3 3
import re
4 4
from unittest import mock
5
from urllib import parse
5 6

  
6 7
import pytest
7 8
from django.apps import apps
......
12 13
from django.test.client import RequestFactory
13 14
from django.test.utils import CaptureQueriesContext
14 15
from django.urls import reverse
15
from django.utils.six.moves.urllib import parse as urlparse
16 16
from pyquery import PyQuery
17 17
from requests.exceptions import ConnectionError
18 18
from requests.models import Response
......
262 262

  
263 263

  
264 264
def mocked_requests_send(request, **kwargs):
265
    request_url = urlparse.urlparse(request.url)
265
    request_url = parse.urlparse(request.url)
266 266
    data = copy.deepcopy(get_data_from_url(request_url.path))
267 267

  
268 268
    if not isinstance(data, list):
269
-