csu 2.6.13__tar.gz → 2.6.15__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {csu-2.6.13 → csu-2.6.15}/.bumpversion.cfg +1 -1
- {csu-2.6.13 → csu-2.6.15}/.cookiecutterrc +1 -1
- {csu-2.6.13 → csu-2.6.15}/PKG-INFO +3 -3
- {csu-2.6.13 → csu-2.6.15}/README.rst +2 -2
- {csu-2.6.13 → csu-2.6.15}/pyproject.toml +1 -1
- {csu-2.6.13 → csu-2.6.15}/src/csu/__init__.py +1 -1
- {csu-2.6.13 → csu-2.6.15}/src/csu/drf/test_auth.py +8 -8
- {csu-2.6.13 → csu-2.6.15}/src/csu/service.py +41 -3
- {csu-2.6.13 → csu-2.6.15}/src/csu.egg-info/PKG-INFO +3 -3
- {csu-2.6.13 → csu-2.6.15}/tests/conftest.py +3 -0
- {csu-2.6.13 → csu-2.6.15}/tests/test_service.py +25 -25
- {csu-2.6.13 → csu-2.6.15}/tests/test_service_auth.py +8 -7
- {csu-2.6.13 → csu-2.6.15}/tox.ini +8 -9
- {csu-2.6.13 → csu-2.6.15}/.coveragerc +0 -0
- {csu-2.6.13 → csu-2.6.15}/.editorconfig +0 -0
- {csu-2.6.13 → csu-2.6.15}/.github/workflows/github-actions.yml +0 -0
- {csu-2.6.13 → csu-2.6.15}/.pre-commit-config.yaml +0 -0
- {csu-2.6.13 → csu-2.6.15}/.tombi.toml +0 -0
- {csu-2.6.13 → csu-2.6.15}/AUTHORS.rst +0 -0
- {csu-2.6.13 → csu-2.6.15}/CHANGELOG.rst +0 -0
- {csu-2.6.13 → csu-2.6.15}/CONTRIBUTING.rst +0 -0
- {csu-2.6.13 → csu-2.6.15}/LICENSE +0 -0
- {csu-2.6.13 → csu-2.6.15}/MANIFEST.in +0 -0
- {csu-2.6.13 → csu-2.6.15}/ci/bootstrap.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/ci/requirements.txt +0 -0
- {csu-2.6.13 → csu-2.6.15}/ci/templates/.github/workflows/github-actions.yml +0 -0
- {csu-2.6.13 → csu-2.6.15}/pytest.ini +0 -0
- {csu-2.6.13 → csu-2.6.15}/setup.cfg +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/admin.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/conf.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/consts.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/drf/__init__.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/drf/auth.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/drf/fields.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/drf/forms.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/drf/perms.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/drf/phonenumber.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/drf/serializers.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/drf/test_fields.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/drf/test_forms.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/drf/test_phonenumber.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/drf/test_serializers.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/drf/views.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/enums.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/env.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/exceptions.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/export.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/fixups.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/forms/__init__.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/forms/crispy.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/forms/fields.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/gettext.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/gettext_lazy.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/locale/ro/LC_MESSAGES/django.mo +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/locale/ro/LC_MESSAGES/django.po +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/logging.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/management.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/models.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/query.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/routers.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/templates/api_exception.html +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/templates/forms/widgets/opaquewidget.html +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/test_consts.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/test_env.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/test_management.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/test_service.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/test_timezones.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/test_utils.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/test_xml.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/timezones.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/utils.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/views.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/worker/__init__.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/worker/admin.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/worker/asgi.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/worker/engine.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/worker/enums.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/worker/job.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/worker/models.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/worker/registry.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/wsgi.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu/xml.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu.egg-info/SOURCES.txt +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu.egg-info/dependency_links.txt +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu.egg-info/requires.txt +0 -0
- {csu-2.6.13 → csu-2.6.15}/src/csu.egg-info/top_level.txt +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/cassettes/test_service/test_custom_context.yaml +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/cassettes/test_service/test_custom_context_0_retries.yaml +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/cassettes/test_service/test_decoding.yaml +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/cassettes/test_service/test_error.yaml +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/cassettes/test_service/test_logging.yaml +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/cassettes/test_service/test_redirects.yaml +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/cassettes/test_service_auth/test_async.yaml +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/cassettes/test_service_auth/test_async_auth.yaml +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/cassettes/test_service_auth/test_sync.yaml +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/cassettes/test_service_auth/test_sync_auth.yaml +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/exampleworker.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/test_exampleworker.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/test_exceptions.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/test_logging.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/test_models.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/test_views.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/test_worker.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/testproject/__init__.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/testproject/fixtures/testuser.json +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/testproject/models.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/testproject/settings.py +0 -0
- {csu-2.6.13 → csu-2.6.15}/tests/testproject/urls.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: csu
|
|
3
|
-
Version: 2.6.
|
|
3
|
+
Version: 2.6.15
|
|
4
4
|
Summary: Clean Slate Utils - bunch of utility code, mostly Django/DRF specific.
|
|
5
5
|
Author-email: Ionel Cristian Mărieș <contact@ionelmc.ro>
|
|
6
6
|
License-Expression: BSD-2-Clause
|
|
@@ -69,9 +69,9 @@ Overview
|
|
|
69
69
|
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/csu.svg
|
|
70
70
|
:alt: Supported implementations
|
|
71
71
|
:target: https://pypi.org/project/csu
|
|
72
|
-
.. |commits-since| image:: https://img.shields.io/github/commits-since/ionelmc/python-csu/v2.6.
|
|
72
|
+
.. |commits-since| image:: https://img.shields.io/github/commits-since/ionelmc/python-csu/v2.6.15.svg
|
|
73
73
|
:alt: Commits since latest release
|
|
74
|
-
:target: https://github.com/ionelmc/python-csu/compare/v2.6.
|
|
74
|
+
:target: https://github.com/ionelmc/python-csu/compare/v2.6.15...main
|
|
75
75
|
.. |scrutinizer| image:: https://img.shields.io/scrutinizer/quality/g/ionelmc/python-csu/main.svg
|
|
76
76
|
:alt: Scrutinizer Status
|
|
77
77
|
:target: https://scrutinizer-ci.com/g/ionelmc/python-csu/
|
|
@@ -34,9 +34,9 @@ Overview
|
|
|
34
34
|
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/csu.svg
|
|
35
35
|
:alt: Supported implementations
|
|
36
36
|
:target: https://pypi.org/project/csu
|
|
37
|
-
.. |commits-since| image:: https://img.shields.io/github/commits-since/ionelmc/python-csu/v2.6.
|
|
37
|
+
.. |commits-since| image:: https://img.shields.io/github/commits-since/ionelmc/python-csu/v2.6.15.svg
|
|
38
38
|
:alt: Commits since latest release
|
|
39
|
-
:target: https://github.com/ionelmc/python-csu/compare/v2.6.
|
|
39
|
+
:target: https://github.com/ionelmc/python-csu/compare/v2.6.15...main
|
|
40
40
|
.. |scrutinizer| image:: https://img.shields.io/scrutinizer/quality/g/ionelmc/python-csu/main.svg
|
|
41
41
|
:alt: Scrutinizer Status
|
|
42
42
|
:target: https://scrutinizer-ci.com/g/ionelmc/python-csu/
|
|
@@ -10,21 +10,21 @@ class StrTokenAuthentication(auth.BearerTokenAuthentication):
|
|
|
10
10
|
|
|
11
11
|
def test_one_token_auth(mocker):
|
|
12
12
|
spy = mocker.spy(auth, "compare_digest")
|
|
13
|
-
assert StrTokenAuthentication().authenticate(SimpleNamespace(
|
|
13
|
+
assert StrTokenAuthentication().authenticate(SimpleNamespace(headers={"authorization": b"Bearer 123"})) == (None, "123")
|
|
14
14
|
assert spy.call_args_list == [call("123", "123")]
|
|
15
15
|
assert spy.spy_return_list == [True]
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def test_one_token_auth_longer(mocker):
|
|
19
19
|
spy = mocker.spy(auth, "compare_digest")
|
|
20
|
-
assert StrTokenAuthentication().authenticate(SimpleNamespace(
|
|
20
|
+
assert StrTokenAuthentication().authenticate(SimpleNamespace(headers={"authorization": b"Bearer 1234"})) is None
|
|
21
21
|
assert spy.call_args_list == [call("1234", "123")]
|
|
22
22
|
assert spy.spy_return_list == [False]
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def test_one_token_auth_shorter(mocker):
|
|
26
26
|
spy = mocker.spy(auth, "compare_digest")
|
|
27
|
-
assert StrTokenAuthentication().authenticate(SimpleNamespace(
|
|
27
|
+
assert StrTokenAuthentication().authenticate(SimpleNamespace(headers={"authorization": b"Bearer 12"})) is None
|
|
28
28
|
assert spy.call_args_list == [call("12", "123")]
|
|
29
29
|
assert spy.spy_return_list == [False]
|
|
30
30
|
|
|
@@ -35,7 +35,7 @@ class ListTokenAuthentication(auth.BearerTokenAuthentication):
|
|
|
35
35
|
|
|
36
36
|
def test_multiple_token_auth_1(mocker):
|
|
37
37
|
spy = mocker.spy(auth, "compare_digest")
|
|
38
|
-
assert ListTokenAuthentication().authenticate(SimpleNamespace(
|
|
38
|
+
assert ListTokenAuthentication().authenticate(SimpleNamespace(headers={"authorization": b"Bearer 123"})) == (None, "123")
|
|
39
39
|
assert spy.call_args_list == [
|
|
40
40
|
call("123", "123"),
|
|
41
41
|
call("123", "1234"),
|
|
@@ -46,7 +46,7 @@ def test_multiple_token_auth_1(mocker):
|
|
|
46
46
|
|
|
47
47
|
def test_multiple_token_auth_2(mocker):
|
|
48
48
|
spy = mocker.spy(auth, "compare_digest")
|
|
49
|
-
assert ListTokenAuthentication().authenticate(SimpleNamespace(
|
|
49
|
+
assert ListTokenAuthentication().authenticate(SimpleNamespace(headers={"authorization": b"Bearer 1234"})) == (None, "1234")
|
|
50
50
|
assert spy.call_args_list == [
|
|
51
51
|
call("1234", "123"),
|
|
52
52
|
call("1234", "1234"),
|
|
@@ -57,7 +57,7 @@ def test_multiple_token_auth_2(mocker):
|
|
|
57
57
|
|
|
58
58
|
def test_multiple_token_auth_3(mocker):
|
|
59
59
|
spy = mocker.spy(auth, "compare_digest")
|
|
60
|
-
assert ListTokenAuthentication().authenticate(SimpleNamespace(
|
|
60
|
+
assert ListTokenAuthentication().authenticate(SimpleNamespace(headers={"authorization": b"Bearer ABC"})) == (None, "ABC")
|
|
61
61
|
assert spy.call_args_list == [
|
|
62
62
|
call("ABC", "123"),
|
|
63
63
|
call("ABC", "1234"),
|
|
@@ -68,7 +68,7 @@ def test_multiple_token_auth_3(mocker):
|
|
|
68
68
|
|
|
69
69
|
def test_multiple_token_auth_shorter(mocker):
|
|
70
70
|
spy = mocker.spy(auth, "compare_digest")
|
|
71
|
-
assert ListTokenAuthentication().authenticate(SimpleNamespace(
|
|
71
|
+
assert ListTokenAuthentication().authenticate(SimpleNamespace(headers={"authorization": b"Bearer 12"})) is None
|
|
72
72
|
assert spy.call_args_list == [
|
|
73
73
|
call("12", "123"),
|
|
74
74
|
call("12", "1234"),
|
|
@@ -79,7 +79,7 @@ def test_multiple_token_auth_shorter(mocker):
|
|
|
79
79
|
|
|
80
80
|
def test_multiple_token_auth_case(mocker):
|
|
81
81
|
spy = mocker.spy(auth, "compare_digest")
|
|
82
|
-
assert ListTokenAuthentication().authenticate(SimpleNamespace(
|
|
82
|
+
assert ListTokenAuthentication().authenticate(SimpleNamespace(headers={"authorization": b"Bearer abc"})) is None
|
|
83
83
|
assert spy.call_args_list == [
|
|
84
84
|
call("abc", "123"),
|
|
85
85
|
call("abc", "1234"),
|
|
@@ -6,6 +6,7 @@ from logging import getLogger
|
|
|
6
6
|
from traceback import format_exc
|
|
7
7
|
from typing import Any
|
|
8
8
|
from typing import Self
|
|
9
|
+
from urllib.parse import urlunparse
|
|
9
10
|
|
|
10
11
|
from niquests import AsyncResponse
|
|
11
12
|
from niquests import AsyncSession
|
|
@@ -16,8 +17,10 @@ from niquests import Session
|
|
|
16
17
|
from niquests.auth import AsyncAuthBase
|
|
17
18
|
from niquests.auth import AuthBase
|
|
18
19
|
from niquests.exceptions import ConnectionError
|
|
20
|
+
from niquests.structures import CaseInsensitiveDict
|
|
19
21
|
from niquests.typing import TLSClientCertType
|
|
20
22
|
from niquests.typing import TLSVerifyType
|
|
23
|
+
from urllib3.util import parse_url
|
|
21
24
|
|
|
22
25
|
from .conf import SERVICE_LOGGING_REQUEST_BODY_LIMIT
|
|
23
26
|
from .conf import SERVICE_LOGGING_REQUEST_SHOW_HEADERS
|
|
@@ -40,6 +43,7 @@ from .logging import trim_auth_info
|
|
|
40
43
|
|
|
41
44
|
class HTTPServiceResponse:
|
|
42
45
|
status: int
|
|
46
|
+
headers: CaseInsensitiveDict[str, str]
|
|
43
47
|
http_response: Response | AsyncResponse
|
|
44
48
|
event_id: str
|
|
45
49
|
json: list | dict | None = None
|
|
@@ -49,6 +53,7 @@ class HTTPServiceResponse:
|
|
|
49
53
|
def __init__(self, http_response: Response, *, content: bytes, text: str, json=None, event_id=None):
|
|
50
54
|
assert http_response.status_code, f"{http_response=} doesn't have a status code"
|
|
51
55
|
self.status = http_response.status_code
|
|
56
|
+
self.headers = http_response.headers
|
|
52
57
|
self.http_response = http_response
|
|
53
58
|
self.event_id = event_id
|
|
54
59
|
self.content = content
|
|
@@ -256,13 +261,16 @@ class HTTPServiceContext[RTYPE = HTTPServiceResponse]:
|
|
|
256
261
|
return self.client.prepare_request(request)
|
|
257
262
|
|
|
258
263
|
def handle_retriable_failure(self, method, url, exc, retries_left, retry_budget):
|
|
264
|
+
parsed_url = parse_url(url)
|
|
265
|
+
netloc = f"{parsed_url.host}:{parsed_url.port}" if parsed_url.port else parsed_url.host
|
|
266
|
+
clean_url = urlunparse((parsed_url.scheme, netloc, parsed_url.path, None, None, None))
|
|
259
267
|
if retries_left:
|
|
260
|
-
self.logger.error("[%s] %s
|
|
268
|
+
self.logger.error(f"[%s] %s {clean_url} !> %r (will retry %s more times)\n%s", self.short_id, method, exc, retries_left, format_exc(limit=5))
|
|
261
269
|
else:
|
|
262
270
|
if retry_budget:
|
|
263
|
-
self.logger.error("[%s] %s
|
|
271
|
+
self.logger.error(f"[%s] %s {clean_url} !> %r (exhausted retries)", self.short_id, method, exc)
|
|
264
272
|
else:
|
|
265
|
-
self.logger.error("[%s] %s
|
|
273
|
+
self.logger.error(f"[%s] %s {clean_url} !> %r (no retry)", self.short_id, method, exc)
|
|
266
274
|
raise InternalServiceError(exc, event_id=self.event_id) from exc
|
|
267
275
|
|
|
268
276
|
def request(
|
|
@@ -460,6 +468,21 @@ class HTTPService[CT = HTTPServiceContext]:
|
|
|
460
468
|
return self.context_class(self, **self.context_defaults, **kwargs)
|
|
461
469
|
|
|
462
470
|
def auth(self, request: PreparedRequest, context: CT) -> PreparedRequest:
|
|
471
|
+
"""
|
|
472
|
+
Example::
|
|
473
|
+
|
|
474
|
+
def auth(self, request: PreparedRequest, context: HTTPServiceContext) -> PreparedRequest:
|
|
475
|
+
response = context.request("POST", "post", json={"foobar": 123}, auth=False)
|
|
476
|
+
assert response.json["json"] == {"foobar": 123}
|
|
477
|
+
request.headers["X-Auth"] = "123"
|
|
478
|
+
return request
|
|
479
|
+
|
|
480
|
+
Alternatively, if the auth is extremely simple you can just inject a builtin auth class::
|
|
481
|
+
|
|
482
|
+
def __init__(self, config):
|
|
483
|
+
super().__init__(config)
|
|
484
|
+
self.context_defaults = {"auth": HTTPDigestAuth(config['USERNAME'], config['password'])}
|
|
485
|
+
"""
|
|
463
486
|
return request
|
|
464
487
|
|
|
465
488
|
|
|
@@ -470,4 +493,19 @@ class AsyncHTTPService[ACT = AsyncHTTPServiceContext](HTTPService[ACT]):
|
|
|
470
493
|
return self.context_class(self, **self.context_defaults, **kwargs)
|
|
471
494
|
|
|
472
495
|
async def auth(self, request: PreparedRequest, context: ACT) -> PreparedRequest:
|
|
496
|
+
"""
|
|
497
|
+
Example::
|
|
498
|
+
|
|
499
|
+
async def auth(self, request: PreparedRequest, context: AsyncHTTPServiceContext) -> PreparedRequest:
|
|
500
|
+
response = await context.request("POST", "post", json={"foobar": 123}, auth=False)
|
|
501
|
+
assert response.json["json"] == {"foobar": 123}
|
|
502
|
+
request.headers["X-Auth"] = "123"
|
|
503
|
+
return request
|
|
504
|
+
|
|
505
|
+
Alternatively, if the auth is extremely simple you can just inject a builtin auth class::
|
|
506
|
+
|
|
507
|
+
def __init__(self, config):
|
|
508
|
+
super().__init__(config)
|
|
509
|
+
self.context_defaults = {"auth": HTTPDigestAuth(config['USERNAME'], config['password'])}
|
|
510
|
+
"""
|
|
473
511
|
return request
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: csu
|
|
3
|
-
Version: 2.6.
|
|
3
|
+
Version: 2.6.15
|
|
4
4
|
Summary: Clean Slate Utils - bunch of utility code, mostly Django/DRF specific.
|
|
5
5
|
Author-email: Ionel Cristian Mărieș <contact@ionelmc.ro>
|
|
6
6
|
License-Expression: BSD-2-Clause
|
|
@@ -69,9 +69,9 @@ Overview
|
|
|
69
69
|
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/csu.svg
|
|
70
70
|
:alt: Supported implementations
|
|
71
71
|
:target: https://pypi.org/project/csu
|
|
72
|
-
.. |commits-since| image:: https://img.shields.io/github/commits-since/ionelmc/python-csu/v2.6.
|
|
72
|
+
.. |commits-since| image:: https://img.shields.io/github/commits-since/ionelmc/python-csu/v2.6.15.svg
|
|
73
73
|
:alt: Commits since latest release
|
|
74
|
-
:target: https://github.com/ionelmc/python-csu/compare/v2.6.
|
|
74
|
+
:target: https://github.com/ionelmc/python-csu/compare/v2.6.15...main
|
|
75
75
|
.. |scrutinizer| image:: https://img.shields.io/scrutinizer/quality/g/ionelmc/python-csu/main.svg
|
|
76
76
|
:alt: Scrutinizer Status
|
|
77
77
|
:target: https://scrutinizer-ci.com/g/ionelmc/python-csu/
|
|
@@ -20,6 +20,7 @@ from urllib3 import HTTPHeaderDict
|
|
|
20
20
|
from vcr.errors import CannotOverwriteExistingCassetteException
|
|
21
21
|
from vcr.patch import CassettePatcherBuilder
|
|
22
22
|
from vcr.request import Request
|
|
23
|
+
from vcr.stubs import VCRFakeSocket
|
|
23
24
|
|
|
24
25
|
from csu import exceptions
|
|
25
26
|
|
|
@@ -30,6 +31,8 @@ _original_build = CassettePatcherBuilder.build
|
|
|
30
31
|
|
|
31
32
|
_DEFAULT_PORTS = {"https": 443, "http": 80}
|
|
32
33
|
|
|
34
|
+
VCRFakeSocket.gettimeout = lambda: None
|
|
35
|
+
|
|
33
36
|
|
|
34
37
|
@pytest.fixture(scope="session")
|
|
35
38
|
def vcr_config():
|
|
@@ -185,7 +185,7 @@ INFO | [00001] GET [&HTTPBIN]/status/599
|
|
|
185
185
|
Accept: '*/*'
|
|
186
186
|
Accept-Encoding: 'gzip, deflate, br'
|
|
187
187
|
Connection: 'keep-alive'
|
|
188
|
-
User-Agent: 'niquests/3.
|
|
188
|
+
User-Agent: 'niquests/3.21.2'\
|
|
189
189
|
""",
|
|
190
190
|
"""\
|
|
191
191
|
INFO | [00001] GET [&HTTPBIN]/status/599 => 599 in 0.0000s (HNone)
|
|
@@ -232,7 +232,7 @@ INFO | [00001] GET [&HTTPBIN]/status/418
|
|
|
232
232
|
Accept: '*/*'
|
|
233
233
|
Accept-Encoding: 'gzip, deflate, br'
|
|
234
234
|
Connection: 'keep-alive'
|
|
235
|
-
User-Agent: 'niquests/3.
|
|
235
|
+
User-Agent: 'niquests/3.21.2'\
|
|
236
236
|
""",
|
|
237
237
|
'''\
|
|
238
238
|
INFO | [00001] GET [&HTTPBIN]/status/418 => 418 in 0.0000s (HNone)
|
|
@@ -256,7 +256,7 @@ ERROR | (renderer: NoneType)
|
|
|
256
256
|
{}
|
|
257
257
|
---------------------------------------------------------------- traceback -----------------------------------------------------------------
|
|
258
258
|
Traceback (most recent call last):
|
|
259
|
-
File "[&MODELS_PATH]", line
|
|
259
|
+
File "[&MODELS_PATH]", line 1594, in json
|
|
260
260
|
return _json.loads(str(encoding_guess), **kwargs)
|
|
261
261
|
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
262
262
|
File "[&JSON_PATH]", line 365, in loads
|
|
@@ -272,9 +272,9 @@ json.decoder.JSONDecodeError: Expecting value: line 2 column 5 (char 5)
|
|
|
272
272
|
During handling of the above exception, another exception occurred:
|
|
273
273
|
|
|
274
274
|
Traceback (most recent call last):
|
|
275
|
-
File "[&SERVICE_PATH]", line
|
|
275
|
+
File "[&SERVICE_PATH]", line 236, in handle_process_response
|
|
276
276
|
json = response.json(parse_float=Decimal)
|
|
277
|
-
File "[&MODELS_PATH]", line
|
|
277
|
+
File "[&MODELS_PATH]", line 1596, in json
|
|
278
278
|
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
|
|
279
279
|
niquests.exceptions.JSONDecodeError: Expecting value: line 2 column 5 (char 5)
|
|
280
280
|
|
|
@@ -287,10 +287,10 @@ Traceback (most recent call last):
|
|
|
287
287
|
File "[&TEST_PATH]", line 78, in json
|
|
288
288
|
return ctx.request("GET", "status/418", accept_statuses=[418]).json
|
|
289
289
|
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
290
|
-
File "[&SERVICE_PATH]", line
|
|
290
|
+
File "[&SERVICE_PATH]", line 317, in request
|
|
291
291
|
return self.handle_process_response(response, expect_json=expect_json)
|
|
292
292
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
293
|
-
File "[&SERVICE_PATH]", line
|
|
293
|
+
File "[&SERVICE_PATH]", line 238, in handle_process_response
|
|
294
294
|
raise DecodeError(response, exc, event_id=self.event_id) from exc
|
|
295
295
|
csu.exceptions.DecodeError: DecodeError(JSONDecodeError('Expecting value: line 2 column 5 (char 5)'), response=<Response Dummy [418]>)
|
|
296
296
|
(418, b'\\n -=[ teapot ]=-\\n\\n _...._\\n .\\' _ _ `.\\n | ."` ^ `". _,\\n \\\\_;`"---"`|//\\n | ;/\\n \\\\_ _/\\n `"""`\\n')
|
|
@@ -325,7 +325,7 @@ INFO | [00001] GET [&HTTPBIN]/status/599
|
|
|
325
325
|
Accept: '*/*'
|
|
326
326
|
Accept-Encoding: 'gzip, deflate, br'
|
|
327
327
|
Connection: 'keep-alive'
|
|
328
|
-
User-Agent: 'niquests/3.
|
|
328
|
+
User-Agent: 'niquests/3.21.2'\
|
|
329
329
|
""",
|
|
330
330
|
"""\
|
|
331
331
|
INFO | [00001] GET [&HTTPBIN]/status/599 => 599 in 0.0000s (HNone)
|
|
@@ -352,7 +352,7 @@ Traceback (most recent call last):
|
|
|
352
352
|
File "[&TEST_PATH]", line 47, in error
|
|
353
353
|
return ctx.request("GET", "status/599", expect_json=False)
|
|
354
354
|
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
355
|
-
File "[&SERVICE_PATH]", line
|
|
355
|
+
File "[&SERVICE_PATH]", line 316, in request
|
|
356
356
|
raise UnexpectedStatusError(response, accept_statuses, event_id=self.event_id)
|
|
357
357
|
csu.exceptions.UnexpectedStatusError: UnexpectedStatusError(<Response Dummy [599]>, accept_statuses=[200])
|
|
358
358
|
(599, b'')
|
|
@@ -530,7 +530,7 @@ INFO | [00001] POST [&HTTPBIN]/anything?foo=bar&accept_statuses=%7B999%7D&exp
|
|
|
530
530
|
Accept-Encoding: 'gzip, deflate, br'
|
|
531
531
|
Connection: 'keep-alive'
|
|
532
532
|
Content-Length: '27'
|
|
533
|
-
User-Agent: 'niquests/3.
|
|
533
|
+
User-Agent: 'niquests/3.21.2'
|
|
534
534
|
------------------------------------------------ request body (no content-type - 27 bytes) -------------------------------------------------
|
|
535
535
|
"config={'custom': 'config'}"
|
|
536
536
|
============================================================================================================================================\
|
|
@@ -550,9 +550,9 @@ INFO | [00001] POST [&HTTPBIN]/anything?foo=bar&accept_statuses=%7B999%7D&exp
|
|
|
550
550
|
============================================================================================================================================\
|
|
551
551
|
""",
|
|
552
552
|
"""\
|
|
553
|
-
ERROR | [00001] POST [&HTTPBIN]/anything
|
|
553
|
+
ERROR | [00001] POST [&HTTPBIN]/anything !> RetryableStatusError('200 not in [999] but in [200]', 200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"3","retry_count":"0","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=3&retry_count=0&retry_statuses={200}"}\\n', event_id=PCC00001000) (will retry 3 more times)
|
|
554
554
|
Traceback (most recent call last):
|
|
555
|
-
File "[&SERVICE_PATH]", line
|
|
555
|
+
File "[&SERVICE_PATH]", line 314, in request
|
|
556
556
|
raise RetryableStatusError(response, accept_statuses, retry_statuses, event_id=self.event_id)
|
|
557
557
|
csu.exceptions.RetryableStatusError: RetryableStatusError(<Response Dummy [200]>, accept_statuses=[999], retry_statuses=[200])
|
|
558
558
|
(200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"3","retry_count":"0","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=3&retry_count=0&retry_statuses={200}"}\\n')
|
|
@@ -564,7 +564,7 @@ INFO | [00001] POST [&HTTPBIN]/anything?foo=bar&accept_statuses=%7B999%7D&exp
|
|
|
564
564
|
Accept-Encoding: 'gzip, deflate, br'
|
|
565
565
|
Connection: 'keep-alive'
|
|
566
566
|
Content-Length: '27'
|
|
567
|
-
User-Agent: 'niquests/3.
|
|
567
|
+
User-Agent: 'niquests/3.21.2'
|
|
568
568
|
------------------------------------------------ request body (no content-type - 27 bytes) -------------------------------------------------
|
|
569
569
|
"config={'custom': 'config'}"
|
|
570
570
|
============================================================================================================================================\
|
|
@@ -584,9 +584,9 @@ INFO | [00001] POST [&HTTPBIN]/anything?foo=bar&accept_statuses=%7B999%7D&exp
|
|
|
584
584
|
============================================================================================================================================\
|
|
585
585
|
""",
|
|
586
586
|
"""\
|
|
587
|
-
ERROR | [00001] POST [&HTTPBIN]/anything
|
|
587
|
+
ERROR | [00001] POST [&HTTPBIN]/anything !> RetryableStatusError('200 not in [999] but in [200]', 200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"2","retry_count":"1","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=2&retry_count=1&retry_statuses={200}"}\\n', event_id=PCC00001000) (will retry 2 more times)
|
|
588
588
|
Traceback (most recent call last):
|
|
589
|
-
File "[&SERVICE_PATH]", line
|
|
589
|
+
File "[&SERVICE_PATH]", line 314, in request
|
|
590
590
|
raise RetryableStatusError(response, accept_statuses, retry_statuses, event_id=self.event_id)
|
|
591
591
|
csu.exceptions.RetryableStatusError: RetryableStatusError(<Response Dummy [200]>, accept_statuses=[999], retry_statuses=[200])
|
|
592
592
|
(200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"2","retry_count":"1","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=2&retry_count=1&retry_statuses={200}"}\\n')
|
|
@@ -598,7 +598,7 @@ INFO | [00001] POST [&HTTPBIN]/anything?foo=bar&accept_statuses=%7B999%7D&exp
|
|
|
598
598
|
Accept-Encoding: 'gzip, deflate, br'
|
|
599
599
|
Connection: 'keep-alive'
|
|
600
600
|
Content-Length: '27'
|
|
601
|
-
User-Agent: 'niquests/3.
|
|
601
|
+
User-Agent: 'niquests/3.21.2'
|
|
602
602
|
------------------------------------------------ request body (no content-type - 27 bytes) -------------------------------------------------
|
|
603
603
|
"config={'custom': 'config'}"
|
|
604
604
|
============================================================================================================================================\
|
|
@@ -618,9 +618,9 @@ INFO | [00001] POST [&HTTPBIN]/anything?foo=bar&accept_statuses=%7B999%7D&exp
|
|
|
618
618
|
============================================================================================================================================\
|
|
619
619
|
""",
|
|
620
620
|
"""\
|
|
621
|
-
ERROR | [00001] POST [&HTTPBIN]/anything
|
|
621
|
+
ERROR | [00001] POST [&HTTPBIN]/anything !> RetryableStatusError('200 not in [999] but in [200]', 200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"1","retry_count":"2","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=1&retry_count=2&retry_statuses={200}"}\\n', event_id=PCC00001000) (will retry 1 more times)
|
|
622
622
|
Traceback (most recent call last):
|
|
623
|
-
File "[&SERVICE_PATH]", line
|
|
623
|
+
File "[&SERVICE_PATH]", line 314, in request
|
|
624
624
|
raise RetryableStatusError(response, accept_statuses, retry_statuses, event_id=self.event_id)
|
|
625
625
|
csu.exceptions.RetryableStatusError: RetryableStatusError(<Response Dummy [200]>, accept_statuses=[999], retry_statuses=[200])
|
|
626
626
|
(200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"1","retry_count":"2","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=1&retry_count=2&retry_statuses={200}"}\\n')
|
|
@@ -632,7 +632,7 @@ INFO | [00001] POST [&HTTPBIN]/anything?foo=bar&accept_statuses=%7B999%7D&exp
|
|
|
632
632
|
Accept-Encoding: 'gzip, deflate, br'
|
|
633
633
|
Connection: 'keep-alive'
|
|
634
634
|
Content-Length: '27'
|
|
635
|
-
User-Agent: 'niquests/3.
|
|
635
|
+
User-Agent: 'niquests/3.21.2'
|
|
636
636
|
------------------------------------------------ request body (no content-type - 27 bytes) -------------------------------------------------
|
|
637
637
|
"config={'custom': 'config'}"
|
|
638
638
|
============================================================================================================================================\
|
|
@@ -651,7 +651,7 @@ INFO | [00001] POST [&HTTPBIN]/anything?foo=bar&accept_statuses=%7B999%7D&exp
|
|
|
651
651
|
b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"0","retry_count":"3","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=0&retry_count=3&retry_statuses={200}"}\\n'
|
|
652
652
|
============================================================================================================================================\
|
|
653
653
|
""",
|
|
654
|
-
'ERROR | [00001] POST [&HTTPBIN]/anything
|
|
654
|
+
'ERROR | [00001] POST [&HTTPBIN]/anything !> RetryableStatusError(\'200 not in [999] but in [200]\', 200, b\'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"0","retry_count":"3","retry_statuses":"{200}"},"data":"config={\\\'custom\\\': \\\'config\\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=0&retry_count=3&retry_statuses={200}"}\\n\', event_id=PCC00001000) (exhausted retries)',
|
|
655
655
|
'WARNING | [00001] __exit__ !> ExhaustedRetriesError(3, [RetryableStatusError(\'200 not in [999] but in [200]\', 200, b\'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"3","retry_count":"0","retry_statuses":"{200}"},"data":"config={\\\'custom\\\': \\\'config\\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=3&retry_count=0&retry_statuses={200}"}\\n\', event_id=PCC00001000), RetryableStatusError(\'200 not in [999] but in [200]\', 200, b\'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"2","retry_count":"1","retry_statuses":"{200}"},"data":"config={\\\'custom\\\': \\\'config\\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=2&retry_count=1&retry_statuses={200}"}\\n\', event_id=PCC00001000), RetryableStatusError(\'200 not in [999] but in [200]\', 200, b\'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"1","retry_count":"2","retry_statuses":"{200}"},"data":"config={\\\'custom\\\': \\\'config\\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=1&retry_count=2&retry_statuses={200}"}\\n\', event_id=PCC00001000), RetryableStatusError(\'200 not in [999] but in [200]\', 200, b\'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"0","retry_count":"3","retry_statuses":"{200}"},"data":"config={\\\'custom\\\': \\\'config\\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=0&retry_count=3&retry_statuses={200}"}\\n\', event_id=PCC00001000)], event_id=PCC00001000)',
|
|
656
656
|
"""\
|
|
657
657
|
ERROR | (renderer: NoneType)
|
|
@@ -668,31 +668,31 @@ ERROR | (renderer: NoneType)
|
|
|
668
668
|
| ...<6 lines>...
|
|
669
669
|
| accept_statuses=[999],
|
|
670
670
|
| )
|
|
671
|
-
| File "[&SERVICE_PATH]", line
|
|
671
|
+
| File "[&SERVICE_PATH]", line 328, in request
|
|
672
672
|
| raise ExhaustedRetriesError(retry_budget, retry_failures, event_id=self.event_id)
|
|
673
673
|
| csu.exceptions.ExhaustedRetriesError: ExhaustedRetriesError(3)
|
|
674
674
|
| ([RetryableStatusError('200 not in [999] but in [200]', 200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"3","retry_count":"0","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=3&retry_count=0&retry_statuses={200}"}\\n', event_id=PCC00001000), RetryableStatusError('200 not in [999] but in [200]', 200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"2","retry_count":"1","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=2&retry_count=1&retry_statuses={200}"}\\n', event_id=PCC00001000), RetryableStatusError('200 not in [999] but in [200]', 200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"1","retry_count":"2","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=1&retry_count=2&retry_statuses={200}"}\\n', event_id=PCC00001000), RetryableStatusError('200 not in [999] but in [200]', 200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"0","retry_count":"3","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=0&retry_count=3&retry_statuses={200}"}\\n', event_id=PCC00001000)],)
|
|
675
675
|
+-+---------------- 1 ----------------
|
|
676
676
|
| Traceback (most recent call last):
|
|
677
|
-
| File "[&SERVICE_PATH]", line
|
|
677
|
+
| File "[&SERVICE_PATH]", line 314, in request
|
|
678
678
|
| raise RetryableStatusError(response, accept_statuses, retry_statuses, event_id=self.event_id)
|
|
679
679
|
| csu.exceptions.RetryableStatusError: RetryableStatusError(<Response Dummy [200]>, accept_statuses=[999], retry_statuses=[200])
|
|
680
680
|
| (200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"3","retry_count":"0","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=3&retry_count=0&retry_statuses={200}"}\\n')
|
|
681
681
|
+---------------- 2 ----------------
|
|
682
682
|
| Traceback (most recent call last):
|
|
683
|
-
| File "[&SERVICE_PATH]", line
|
|
683
|
+
| File "[&SERVICE_PATH]", line 314, in request
|
|
684
684
|
| raise RetryableStatusError(response, accept_statuses, retry_statuses, event_id=self.event_id)
|
|
685
685
|
| csu.exceptions.RetryableStatusError: RetryableStatusError(<Response Dummy [200]>, accept_statuses=[999], retry_statuses=[200])
|
|
686
686
|
| (200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"2","retry_count":"1","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=2&retry_count=1&retry_statuses={200}"}\\n')
|
|
687
687
|
+---------------- 3 ----------------
|
|
688
688
|
| Traceback (most recent call last):
|
|
689
|
-
| File "[&SERVICE_PATH]", line
|
|
689
|
+
| File "[&SERVICE_PATH]", line 314, in request
|
|
690
690
|
| raise RetryableStatusError(response, accept_statuses, retry_statuses, event_id=self.event_id)
|
|
691
691
|
| csu.exceptions.RetryableStatusError: RetryableStatusError(<Response Dummy [200]>, accept_statuses=[999], retry_statuses=[200])
|
|
692
692
|
| (200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"1","retry_count":"2","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=1&retry_count=2&retry_statuses={200}"}\\n')
|
|
693
693
|
+---------------- 4 ----------------
|
|
694
694
|
| Traceback (most recent call last):
|
|
695
|
-
| File "[&SERVICE_PATH]", line
|
|
695
|
+
| File "[&SERVICE_PATH]", line 314, in request
|
|
696
696
|
| raise RetryableStatusError(response, accept_statuses, retry_statuses, event_id=self.event_id)
|
|
697
697
|
| csu.exceptions.RetryableStatusError: RetryableStatusError(<Response Dummy [200]>, accept_statuses=[999], retry_statuses=[200])
|
|
698
698
|
| (200, b'{"args":{"accept_statuses":"{999}","expect_json":"true","follow_redirects":"false","foo":"bar","retries_left":"0","retry_count":"3","retry_statuses":"{200}"},"data":"config={\\'custom\\': \\'config\\'}","files":{},"form":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","Content-Length":"27","Host":"127.0.0.1:12345","User-Agent":"python-httpx/0.X.X"},"json":null,"method":"POST","origin":"127.0.0.1","url":"http://127.0.0.1:12345/anything?foo=bar&accept_statuses={999}&expect_json=true&follow_redirects=false&retries_left=0&retry_count=3&retry_statuses={200}"}\\n')
|
|
@@ -7,6 +7,7 @@ from niquests.auth import HTTPBasicAuth
|
|
|
7
7
|
|
|
8
8
|
from csu.exceptions import UnexpectedStatusError
|
|
9
9
|
from csu.service import AsyncHTTPService
|
|
10
|
+
from csu.service import AsyncHTTPServiceContext
|
|
10
11
|
from csu.service import HTTPService
|
|
11
12
|
from csu.service import HTTPServiceContext
|
|
12
13
|
|
|
@@ -32,7 +33,7 @@ class AsyncAuthedService(AsyncHTTPService):
|
|
|
32
33
|
super().__init__(config={"BASE_URL": url, **config})
|
|
33
34
|
self.config = {"custom": "config"}
|
|
34
35
|
|
|
35
|
-
async def auth(self, request: PreparedRequest, context:
|
|
36
|
+
async def auth(self, request: PreparedRequest, context: AsyncHTTPServiceContext) -> PreparedRequest:
|
|
36
37
|
response = await context.request("POST", "post", json={"foobar": 123}, auth=False)
|
|
37
38
|
assert response.json["json"] == {"foobar": 123}
|
|
38
39
|
request.headers["X-Auth"] = "123"
|
|
@@ -80,7 +81,7 @@ INFO | [00001] GET http://[&HTTPBIN]/basic-auth/usr/pwd
|
|
|
80
81
|
Accept-Encoding: 'gzip, deflate, br'
|
|
81
82
|
Authorization: 'Basic dXNyOnB3ZA=='
|
|
82
83
|
Connection: 'keep-alive'
|
|
83
|
-
User-Agent: 'niquests/3.
|
|
84
|
+
User-Agent: 'niquests/3.21.2'\
|
|
84
85
|
""",
|
|
85
86
|
"""\
|
|
86
87
|
INFO | [00001] GET http://[&HTTPBIN]/basic-auth/usr/pwd => 200 in 0.0000s (HNone)
|
|
@@ -120,7 +121,7 @@ INFO | [00001] GET http://[&HTTPBIN]/basic-auth/usr/pwd
|
|
|
120
121
|
Accept-Encoding: 'gzip, deflate, br'
|
|
121
122
|
Authorization: 'Basic dXNyOnB3ZA=='
|
|
122
123
|
Connection: 'keep-alive'
|
|
123
|
-
User-Agent: 'niquests/3.
|
|
124
|
+
User-Agent: 'niquests/3.21.2'\
|
|
124
125
|
""",
|
|
125
126
|
"INFO | Playing response for <Request (GET) http://[&HTTPBIN]/basic-auth/usr/pwd> from cassette",
|
|
126
127
|
"""\
|
|
@@ -161,7 +162,7 @@ INFO | [00001] POST http://[&HTTPBIN]/post
|
|
|
161
162
|
Connection: 'keep-alive'
|
|
162
163
|
Content-Length: '15'
|
|
163
164
|
Content-Type: 'application/json;charset=utf-8'
|
|
164
|
-
User-Agent: 'niquests/3.
|
|
165
|
+
User-Agent: 'niquests/3.21.2'
|
|
165
166
|
---------------------------------------- request body ('application/json;charset=utf-8' - 15 bytes) ----------------------------------------
|
|
166
167
|
b'{"foobar": 123}'
|
|
167
168
|
============================================================================================================================================\
|
|
@@ -186,7 +187,7 @@ INFO | [00001] GET http://[&HTTPBIN]/json
|
|
|
186
187
|
Accept: '*/*'
|
|
187
188
|
Accept-Encoding: 'gzip, deflate, br'
|
|
188
189
|
Connection: 'keep-alive'
|
|
189
|
-
User-Agent: 'niquests/3.
|
|
190
|
+
User-Agent: 'niquests/3.21.2'
|
|
190
191
|
X-Auth: '123'\
|
|
191
192
|
""",
|
|
192
193
|
"""\
|
|
@@ -226,7 +227,7 @@ INFO | [00001] POST [&HTTPBIN]/post
|
|
|
226
227
|
Connection: 'keep-alive'
|
|
227
228
|
Content-Length: '15'
|
|
228
229
|
Content-Type: 'application/json;charset=utf-8'
|
|
229
|
-
User-Agent: 'niquests/3.
|
|
230
|
+
User-Agent: 'niquests/3.21.2'
|
|
230
231
|
---------------------------------------- request body ('application/json;charset=utf-8' - 15 bytes) ----------------------------------------
|
|
231
232
|
b'{"foobar": 123}'
|
|
232
233
|
============================================================================================================================================\
|
|
@@ -252,7 +253,7 @@ INFO | [00001] GET [&HTTPBIN]/json
|
|
|
252
253
|
Accept: '*/*'
|
|
253
254
|
Accept-Encoding: 'gzip, deflate, br'
|
|
254
255
|
Connection: 'keep-alive'
|
|
255
|
-
User-Agent: 'niquests/3.
|
|
256
|
+
User-Agent: 'niquests/3.21.2'
|
|
256
257
|
X-Auth: '123'\
|
|
257
258
|
""",
|
|
258
259
|
"INFO | Playing response for <Request (GET) [&HTTPBIN]/json> from cassette",
|
|
@@ -35,21 +35,20 @@ deps =
|
|
|
35
35
|
pytest-django
|
|
36
36
|
pytest-httpbin
|
|
37
37
|
pytest-recording
|
|
38
|
-
https://github.com/kevin1024/vcrpy/archive/30a721d400b55ced25f5d8a612b8a1ae01240160.zip
|
|
38
|
+
; https://github.com/kevin1024/vcrpy/archive/30a721d400b55ced25f5d8a612b8a1ae01240160.zip
|
|
39
39
|
process-tests
|
|
40
40
|
inline-snapshot
|
|
41
41
|
time-machine
|
|
42
|
-
|
|
43
|
-
django-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
niquests[brotli,http3]==3.18.6
|
|
42
|
+
django-crispy-forms==2.7
|
|
43
|
+
django-import-export==4.4.1
|
|
44
|
+
djangorestframework==3.18.1
|
|
45
|
+
phonenumberslite==9.0.40
|
|
46
|
+
django-phonenumber-field==8.5.0
|
|
47
|
+
niquests[brotli,http3]==3.21.2
|
|
49
48
|
datetimerange==2.3.2
|
|
50
49
|
defusedxml==0.7.1
|
|
51
50
|
django-rosetta
|
|
52
|
-
django==6.0.
|
|
51
|
+
django==6.0.8
|
|
53
52
|
commands =
|
|
54
53
|
{posargs:pytest --cov --cov-report=term-missing --cov-report=xml -vv}
|
|
55
54
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|