tests: remove use of pytest-httpbin (#63302)
This commit is contained in:
parent
eca19698a7
commit
05a3a55e75
|
@ -1,4 +1,5 @@
|
|||
from io import BytesIO
|
||||
from urllib.parse import parse_qsl, urlparse
|
||||
|
||||
import django_webtest
|
||||
import pytest
|
||||
|
@ -210,3 +211,20 @@ def simple_user():
|
|||
@pytest.fixture
|
||||
def admin_user():
|
||||
return User.objects.create_superuser('admin', email=None, password='admin')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def httpbin():
|
||||
@urlmatch(netloc=r'^httpbin\.org$', path=r'^/cookies/set$')
|
||||
def httpbin_cookies_set(url, request):
|
||||
headers = []
|
||||
cookies = {}
|
||||
for key, value in parse_qsl(urlparse(request.url).query):
|
||||
cookies[key] = value
|
||||
headers.append(('Set-Cookie', f'{key}={value}; Path=/'))
|
||||
headers.append(('Location', '/cookies'))
|
||||
return response(200, b'', headers=headers, request=request)
|
||||
|
||||
with HTTMock(httpbin_cookies_set) as fixture:
|
||||
fixture.url = 'http://httpbin.org'
|
||||
yield fixture
|
||||
|
|
|
@ -709,18 +709,18 @@ def test_endpoint_cookies(app, db, monkeypatch, httpbin):
|
|||
assert json_res['cookie2'] == 'foo=bar'
|
||||
|
||||
|
||||
def test_https_warnings(app, db, monkeypatch, httpbin_secure, relax_openssl):
|
||||
def test_https_warnings(app, db, monkeypatch, httpsserver, relax_openssl):
|
||||
from requests.exceptions import SSLError
|
||||
|
||||
resource = tests.utils.make_resource(
|
||||
ArcGIS, base_url='https://example.com/', slug='gis', verify_cert=True
|
||||
)
|
||||
with pytest.raises(SSLError):
|
||||
resource.requests.get(httpbin_secure.join('/get/'))
|
||||
resource.requests.get(httpsserver.url)
|
||||
resource.verify_cert = False
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('error')
|
||||
resource.requests.get(httpbin_secure.join('/get/'))
|
||||
resource.requests.get(httpsserver.url)
|
||||
|
||||
|
||||
def test_endpoint_typed_params(app, db, monkeypatch):
|
||||
|
|
|
@ -465,7 +465,7 @@ def test_log_http_request(caplog):
|
|||
assert extra == {
|
||||
'request_headers': {
|
||||
'Accept': '*/*',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Connection': 'keep-alive',
|
||||
},
|
||||
'request_url': 'https://example.com/',
|
||||
|
|
Loading…
Reference in New Issue