diff --git a/requirements-test.txt b/requirements-test.txt --- a/requirements-test.txt +++ b/requirements-test.txt @@ -6,7 +6,7 @@ pytest pytest-django pytest-mock -requests-mock +requests-mock != 1.9.0, != 1.9.1 swh.core[http] >= 0.0.95 swh.loader.git >= 0.8.0 swh.storage >= 0.1.1 diff --git a/swh/web/api/views/graph.py b/swh/web/api/views/graph.py --- a/swh/web/api/views/graph.py +++ b/swh/web/api/views/graph.py @@ -6,7 +6,6 @@ from distutils.util import strtobool import json from typing import Dict, Iterator, Union -from urllib.parse import quote import requests @@ -136,7 +135,7 @@ "You do not have permission to perform this action.", status=403 ) graph_query_url = get_config()["graph"]["server_url"] - graph_query_url += quote(graph_query) + graph_query_url += graph_query if request.GET: graph_query_url += "?" + request.GET.urlencode(safe="/;:") response = requests.get(graph_query_url, stream=True) diff --git a/swh/web/tests/api/views/test_graph.py b/swh/web/tests/api/views/test_graph.py --- a/swh/web/tests/api/views/test_graph.py +++ b/swh/web/tests/api/views/test_graph.py @@ -6,7 +6,6 @@ import hashlib import json import textwrap -from urllib.parse import quote from hypothesis import given @@ -87,14 +86,11 @@ """ ) - # ensure compatibility with all requests-mock versions - # https://github.com/jamielennox/requests-mock/commit/f072845 - for path in (graph_query, quote(graph_query)): - requests_mock.get( - get_config()["graph"]["server_url"] + path, - text=response_text, - headers={"Content-Type": "text/plain", "Transfer-Encoding": "chunked"}, - ) + requests_mock.get( + get_config()["graph"]["server_url"] + graph_query, + text=response_text, + headers={"Content-Type": "text/plain", "Transfer-Encoding": "chunked"}, + ) url = reverse("api-1-graph", url_args={"graph_query": graph_query}) @@ -152,17 +148,14 @@ """ ) - # ensure compatibility with all requests-mock versions - # https://github.com/jamielennox/requests-mock/commit/f072845 - for path in (graph_query, quote(graph_query)): - requests_mock.get( - get_config()["graph"]["server_url"] + path, - text=response_ndjson, - headers={ - "Content-Type": "application/x-ndjson", - "Transfer-Encoding": "chunked", - }, - ) + requests_mock.get( + get_config()["graph"]["server_url"] + graph_query, + text=response_ndjson, + headers={ + "Content-Type": "application/x-ndjson", + "Transfer-Encoding": "chunked", + }, + ) url = reverse("api-1-graph", url_args={"graph_query": graph_query}) @@ -212,14 +205,11 @@ # set two lines response to check resolved origins cache response_text = response_text + response_text - # ensure compatibility with all requests-mock versions - # https://github.com/jamielennox/requests-mock/commit/f072845 - for path in (graph_query, quote(graph_query)): - requests_mock.get( - get_config()["graph"]["server_url"] + path, - text=response_text, - headers={"Content-Type": content_type, "Transfer-Encoding": "chunked"}, - ) + requests_mock.get( + get_config()["graph"]["server_url"] + graph_query, + text=response_text, + headers={"Content-Type": content_type, "Transfer-Encoding": "chunked"}, + ) url = reverse( "api-1-graph",