workers-runtime-sdk 1.6.5__tar.gz → 1.6.7__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.
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/AGENTS.md +1 -1
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/CHANGELOG.md +22 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/PKG-INFO +1 -1
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/pyproject.toml +9 -1
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/_workers_sdk_entropy_import_context.py +4 -8
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/asgi.py +6 -1
- workers_runtime_sdk-1.6.7/tests/bindings-test/public/data.json +1 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/public/hello.txt +1 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/pyproject.toml +5 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/conftest.py +10 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_analytics_engine.py +24 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_assets.py +35 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_d1.py +498 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_do.py +224 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_images.py +41 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_kv.py +320 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_mtls.py +15 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_queue.py +125 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_r2.py +393 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_ratelimit.py +14 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_vectorize.py +11 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_version_metadata.py +17 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_workflow.py +215 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/worker.py +186 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/worker_durable_object.py +260 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/src/worker_workflow.py +130 -0
- workers_runtime_sdk-1.6.7/tests/bindings-test/wrangler.jsonc +65 -0
- workers_runtime_sdk-1.6.7/tests/conftest.py +267 -0
- workers_runtime_sdk-1.6.7/tests/test_bindings.py +27 -0
- workers_runtime_sdk-1.6.7/tests/test_fastapi.py +44 -0
- workers_runtime_sdk-1.6.7/tests/test_in_workerd.py +151 -0
- workers_runtime_sdk-1.6.7/tests/test_web_frameworks.py +41 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/pyproject.toml +11 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/_client.py +92 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/conftest.py +10 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/__init__.py +0 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/api_urls.py +13 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/auth_backend.py +77 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/drf_auth.py +24 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/drf_serializers.py +36 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/drf_throttling.py +12 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/drf_views.py +134 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/forms.py +39 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/middleware.py +17 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/templatetags/__init__.py +0 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/templatetags/custom_tags.py +13 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/urls.py +67 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/views.py +363 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/templates/base.html +5 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/templates/context_test.html +6 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/templates/csrf_form.html +1 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/templates/hello.html +3 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_async_utilities.py +19 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_auth.py +86 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_caching.py +62 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_cors.py +46 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_csrf.py +69 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_drf_auth_permissions.py +47 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_drf_content_negotiation.py +41 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_drf_serializers.py +68 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_drf_throttling.py +16 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_drf_versioning.py +25 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_drf_views.py +73 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_error_handling.py +32 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_file_uploads.py +57 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_forms.py +50 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_middleware.py +27 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_pagination.py +36 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_request_response.py +98 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_sessions.py +95 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_signals.py +33 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_streaming.py +22 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_templates.py +34 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_url_routing.py +69 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_views_basic.py +71 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/worker.py +206 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/wrangler.jsonc +6 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/public/data.json +1 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/public/index.html +7 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/public/style.css +5 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/pyproject.toml +9 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/src/_client.py +26 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/src/conftest.py +10 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/src/test_assets.py +65 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/src/worker.py +143 -0
- workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/wrangler.jsonc +11 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/asgi/asgi.wd-test +19 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/asgi/pyproject.toml +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/asgi/tests/test_asgi.py +401 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/asgi/worker.py +240 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/asgi/wrangler.jsonc +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/asgi-ws-disconnect/asgi-ws-disconnect.wd-test +19 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/asgi-ws-disconnect/pyproject.toml +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/asgi-ws-disconnect/tests/test_ws_disconnect.py +72 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/asgi-ws-disconnect/worker.py +70 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/asgi-ws-disconnect/wrangler.jsonc +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object/durable-object.wd-test +28 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object/pyproject.toml +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object/worker.py +144 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object/wrangler.jsonc +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-abort/durable-object-abort.wd-test +27 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-abort/pyproject.toml +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-abort/worker.py +57 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-abort/wrangler.jsonc +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-inheritance/durable-object-inheritance.wd-test +40 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-inheritance/pyproject.toml +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-inheritance/worker.py +115 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-inheritance/wrangler.jsonc +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-websocket/durable-object-websocket.wd-test +39 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-websocket/pyproject.toml +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-websocket/tester.js +27 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-websocket/worker.py +43 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-websocket/wrangler.jsonc +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/entropy-patches.wd-test +18 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/pyproject.toml +18 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/tests/test_aiohttp_websocket.py +7 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/tests/test_langsmith.py +8 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/tests/test_numpy.py +9 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/tests/test_pydantic.py +8 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/tests/test_rust_packages.py +10 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/tests/test_ssl_avoidance.py +9 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/worker.py +27 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/wrangler.jsonc +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/python-rpc/pyproject.toml +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/python-rpc/python-rpc.wd-test +34 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/python-rpc/worker.js +101 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/python-rpc/worker.py +384 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/python-rpc/wrangler.jsonc +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/sdk/pyproject.toml +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/sdk/sdk.wd-test +42 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/sdk/server.py +35 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/sdk/tests/test_sdk.py +608 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/sdk/worker.py +71 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/sdk/wrangler.jsonc +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/wsgi/pyproject.toml +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/wsgi/worker.py +205 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/wsgi/wrangler.jsonc +5 -0
- workers_runtime_sdk-1.6.7/tests/workerd-test/wsgi/wsgi.wd-test +19 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/uv.lock +119 -1
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/.gitignore +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/README.md +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/_cloudflare_compat_flags.pyi +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/_pyodide_entrypoint_helper.pyi +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/_workers_sdk_entropy_import_context.pth +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/_workers_sdk_entropy_import_context_loader.py +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/__init__.py +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/blob.py +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/entrypoints.py +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/fetch.py +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/formdata.py +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/py.typed +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/request.py +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/response.py +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/rpc.py +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/types.py +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/utils.py +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/workflows.py +0 -0
- {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/wsgi.py +0 -0
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- version list -->
|
|
4
4
|
|
|
5
|
+
## v1.6.7 (2026-08-05)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- Fix entropy patch for newer pydantic versions
|
|
10
|
+
([#153](https://github.com/cloudflare/workers-py/pull/153),
|
|
11
|
+
[`81a4b6b`](https://github.com/cloudflare/workers-py/commit/81a4b6bad37373e0b448dd2dbedbf6cec0f47b8c))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## v1.6.6 (2026-08-03)
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
- **runtime-sdk**: Percent-decode `scope["path"]` per the ASGI spec
|
|
19
|
+
([#169](https://github.com/cloudflare/workers-py/pull/169),
|
|
20
|
+
[`2138e44`](https://github.com/cloudflare/workers-py/commit/2138e44dc0bc419a1227497576154346da3ea522))
|
|
21
|
+
|
|
22
|
+
- **runtime-sdk**: Percent-decode scope["path"] per the ASGI spec
|
|
23
|
+
([#169](https://github.com/cloudflare/workers-py/pull/169),
|
|
24
|
+
[`2138e44`](https://github.com/cloudflare/workers-py/commit/2138e44dc0bc419a1227497576154346da3ea522))
|
|
25
|
+
|
|
26
|
+
|
|
5
27
|
## v1.6.5 (2026-08-03)
|
|
6
28
|
|
|
7
29
|
### Bug Fixes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: workers-runtime-sdk
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.7
|
|
4
4
|
Summary: Python SDK for Cloudflare Workers
|
|
5
5
|
Project-URL: Homepage, https://github.com/cloudflare/workers-py
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/cloudflare/workers-py/issues
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "workers-runtime-sdk"
|
|
7
|
-
version = "1.6.
|
|
7
|
+
version = "1.6.7"
|
|
8
8
|
description = "Python SDK for Cloudflare Workers"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -20,6 +20,7 @@ dev = [
|
|
|
20
20
|
"pytest>=7.0.0",
|
|
21
21
|
"ruff>=0.1.0",
|
|
22
22
|
"mypy>=1.0.0",
|
|
23
|
+
"requests>=2.28.0",
|
|
23
24
|
]
|
|
24
25
|
|
|
25
26
|
[project.urls]
|
|
@@ -56,6 +57,13 @@ lint.ignore = [
|
|
|
56
57
|
"UP038", # Use X | Y instead of (X, Y)
|
|
57
58
|
]
|
|
58
59
|
lint.flake8-comprehensions.allow-dict-calls-with-keyword-arguments = true
|
|
60
|
+
lint.per-file-ignores."tests/**" = ["PLR2004", "PLR0913"]
|
|
61
|
+
lint.per-file-ignores."tests/workerd-test/**" = ["C901", "PLR0911", "PLR0912", "PLR2004", "PLW0603"]
|
|
62
|
+
lint.per-file-ignores."tests/bindings-test/**" = ["C901", "PLR0911", "PLR0912", "PLR2004", "PLW0603"]
|
|
63
|
+
lint.per-file-ignores."tests/web-frameworks-test/**" = ["C901", "PLR0911", "PLR0912", "PLR2004", "PLW0603"]
|
|
64
|
+
|
|
65
|
+
[tool.pytest.ini_options]
|
|
66
|
+
addopts = ["--ignore=tests/workerd-test", "--ignore=tests/bindings-test", "--ignore=tests/web-frameworks-test"]
|
|
59
67
|
|
|
60
68
|
[tool.mypy]
|
|
61
69
|
packages = ["workers_runtime_sdk"]
|
{workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/_workers_sdk_entropy_import_context.py
RENAMED
|
@@ -93,14 +93,10 @@ def pydantic_core_context(module):
|
|
|
93
93
|
with allow_bad_entropy_calls(1):
|
|
94
94
|
yield
|
|
95
95
|
finally:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
# but only after making the needed entropy call.
|
|
101
|
-
module.validate_core_schema(None)
|
|
102
|
-
except module.SchemaError:
|
|
103
|
-
pass
|
|
96
|
+
# Build a tiny validator instead so any lazy hash-map seeds are initialized
|
|
97
|
+
# before the snapshot is captured.
|
|
98
|
+
with allow_bad_entropy_calls(1):
|
|
99
|
+
module.SchemaValidator({"type": "any"})
|
|
104
100
|
|
|
105
101
|
|
|
106
102
|
@register_exec_patch("aiohttp.http_websocket")
|
|
@@ -3,6 +3,7 @@ from asyncio import Event, Future, Queue, create_task, ensure_future
|
|
|
3
3
|
from collections.abc import Awaitable
|
|
4
4
|
from contextlib import contextmanager
|
|
5
5
|
from typing import Any
|
|
6
|
+
from urllib.parse import unquote
|
|
6
7
|
|
|
7
8
|
import js
|
|
8
9
|
|
|
@@ -55,7 +56,10 @@ def request_to_scope(req, env, ws=False):
|
|
|
55
56
|
url = URL.new(req.url)
|
|
56
57
|
assert url.protocol[-1] == ":"
|
|
57
58
|
scheme = url.protocol[:-1]
|
|
58
|
-
path
|
|
59
|
+
# ASGI requires "path" to be percent-decoded; the encoded original is
|
|
60
|
+
# available to apps via "raw_path".
|
|
61
|
+
# https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope
|
|
62
|
+
path = unquote(url.pathname)
|
|
59
63
|
assert "?".startswith(url.search[0:1])
|
|
60
64
|
query_string = url.search[1:].encode()
|
|
61
65
|
if ws:
|
|
@@ -69,6 +73,7 @@ def request_to_scope(req, env, ws=False):
|
|
|
69
73
|
"method": req.method,
|
|
70
74
|
"scheme": scheme,
|
|
71
75
|
"path": path,
|
|
76
|
+
"raw_path": url.pathname.encode(),
|
|
72
77
|
"query_string": query_string,
|
|
73
78
|
"type": ty,
|
|
74
79
|
"env": env,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"key": "value", "number": 42}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
hello from static assets
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from workers.rpc import _BindingWrapper
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@pytest.mark.asyncio
|
|
7
|
+
async def test_is_wrapped(env):
|
|
8
|
+
assert isinstance(env.ANALYTICS, _BindingWrapper)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.mark.asyncio
|
|
12
|
+
async def test_write_data_point_blobs_and_doubles(env):
|
|
13
|
+
env.ANALYTICS.writeDataPoint(
|
|
14
|
+
{
|
|
15
|
+
"blobs": ["blob1", "blob2"],
|
|
16
|
+
"doubles": [1.0, 2.5],
|
|
17
|
+
"indexes": ["idx"],
|
|
18
|
+
}
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.mark.asyncio
|
|
23
|
+
async def test_write_data_point_empty(env):
|
|
24
|
+
env.ANALYTICS.writeDataPoint({})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from workers.rpc import _FetcherWrapper
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@pytest.mark.asyncio
|
|
7
|
+
async def test_is_fetcher_wrapper(env):
|
|
8
|
+
assert isinstance(env.ASSETS, _FetcherWrapper)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.mark.asyncio
|
|
12
|
+
async def test_fetch_text_file(env):
|
|
13
|
+
resp = await env.ASSETS.fetch("https://assets.local/hello.txt")
|
|
14
|
+
text = await resp.text()
|
|
15
|
+
assert text.strip() == "hello from static assets"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@pytest.mark.asyncio
|
|
19
|
+
async def test_fetch_json_file(env):
|
|
20
|
+
resp = await env.ASSETS.fetch("https://assets.local/data.json")
|
|
21
|
+
data = await resp.json()
|
|
22
|
+
assert data["key"] == "value"
|
|
23
|
+
assert data["number"] == 42
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@pytest.mark.asyncio
|
|
27
|
+
async def test_fetch_returns_404_for_missing(env):
|
|
28
|
+
resp = await env.ASSETS.fetch("https://assets.local/nonexistent.txt")
|
|
29
|
+
assert resp.status == 404
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@pytest.mark.asyncio
|
|
33
|
+
async def test_fetch_content_type(env):
|
|
34
|
+
resp = await env.ASSETS.fetch("https://assets.local/data.json")
|
|
35
|
+
assert "application/json" in resp.headers.get("content-type")
|