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.
Files changed (158) hide show
  1. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/AGENTS.md +1 -1
  2. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/CHANGELOG.md +22 -0
  3. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/PKG-INFO +1 -1
  4. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/pyproject.toml +9 -1
  5. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/_workers_sdk_entropy_import_context.py +4 -8
  6. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/asgi.py +6 -1
  7. workers_runtime_sdk-1.6.7/tests/bindings-test/public/data.json +1 -0
  8. workers_runtime_sdk-1.6.7/tests/bindings-test/public/hello.txt +1 -0
  9. workers_runtime_sdk-1.6.7/tests/bindings-test/pyproject.toml +5 -0
  10. workers_runtime_sdk-1.6.7/tests/bindings-test/src/conftest.py +10 -0
  11. workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_analytics_engine.py +24 -0
  12. workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_assets.py +35 -0
  13. workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_d1.py +498 -0
  14. workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_do.py +224 -0
  15. workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_images.py +41 -0
  16. workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_kv.py +320 -0
  17. workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_mtls.py +15 -0
  18. workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_queue.py +125 -0
  19. workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_r2.py +393 -0
  20. workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_ratelimit.py +14 -0
  21. workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_vectorize.py +11 -0
  22. workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_version_metadata.py +17 -0
  23. workers_runtime_sdk-1.6.7/tests/bindings-test/src/test_workflow.py +215 -0
  24. workers_runtime_sdk-1.6.7/tests/bindings-test/src/worker.py +186 -0
  25. workers_runtime_sdk-1.6.7/tests/bindings-test/src/worker_durable_object.py +260 -0
  26. workers_runtime_sdk-1.6.7/tests/bindings-test/src/worker_workflow.py +130 -0
  27. workers_runtime_sdk-1.6.7/tests/bindings-test/wrangler.jsonc +65 -0
  28. workers_runtime_sdk-1.6.7/tests/conftest.py +267 -0
  29. workers_runtime_sdk-1.6.7/tests/test_bindings.py +27 -0
  30. workers_runtime_sdk-1.6.7/tests/test_fastapi.py +44 -0
  31. workers_runtime_sdk-1.6.7/tests/test_in_workerd.py +151 -0
  32. workers_runtime_sdk-1.6.7/tests/test_web_frameworks.py +41 -0
  33. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/pyproject.toml +11 -0
  34. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/_client.py +92 -0
  35. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/conftest.py +10 -0
  36. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/__init__.py +0 -0
  37. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/api_urls.py +13 -0
  38. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/auth_backend.py +77 -0
  39. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/drf_auth.py +24 -0
  40. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/drf_serializers.py +36 -0
  41. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/drf_throttling.py +12 -0
  42. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/drf_views.py +134 -0
  43. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/forms.py +39 -0
  44. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/middleware.py +17 -0
  45. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/templatetags/__init__.py +0 -0
  46. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/templatetags/custom_tags.py +13 -0
  47. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/urls.py +67 -0
  48. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/django_app/views.py +363 -0
  49. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/templates/base.html +5 -0
  50. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/templates/context_test.html +6 -0
  51. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/templates/csrf_form.html +1 -0
  52. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/templates/hello.html +3 -0
  53. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_async_utilities.py +19 -0
  54. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_auth.py +86 -0
  55. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_caching.py +62 -0
  56. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_cors.py +46 -0
  57. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_csrf.py +69 -0
  58. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_drf_auth_permissions.py +47 -0
  59. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_drf_content_negotiation.py +41 -0
  60. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_drf_serializers.py +68 -0
  61. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_drf_throttling.py +16 -0
  62. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_drf_versioning.py +25 -0
  63. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_drf_views.py +73 -0
  64. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_error_handling.py +32 -0
  65. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_file_uploads.py +57 -0
  66. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_forms.py +50 -0
  67. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_middleware.py +27 -0
  68. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_pagination.py +36 -0
  69. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_request_response.py +98 -0
  70. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_sessions.py +95 -0
  71. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_signals.py +33 -0
  72. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_streaming.py +22 -0
  73. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_templates.py +34 -0
  74. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_url_routing.py +69 -0
  75. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/test_views_basic.py +71 -0
  76. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/src/worker.py +206 -0
  77. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/django-async/wrangler.jsonc +6 -0
  78. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/public/data.json +1 -0
  79. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/public/index.html +7 -0
  80. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/public/style.css +5 -0
  81. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/pyproject.toml +9 -0
  82. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/src/_client.py +26 -0
  83. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/src/conftest.py +10 -0
  84. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/src/test_assets.py +65 -0
  85. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/src/worker.py +143 -0
  86. workers_runtime_sdk-1.6.7/tests/web-frameworks-test/fastapi-tests/wrangler.jsonc +11 -0
  87. workers_runtime_sdk-1.6.7/tests/workerd-test/asgi/asgi.wd-test +19 -0
  88. workers_runtime_sdk-1.6.7/tests/workerd-test/asgi/pyproject.toml +5 -0
  89. workers_runtime_sdk-1.6.7/tests/workerd-test/asgi/tests/test_asgi.py +401 -0
  90. workers_runtime_sdk-1.6.7/tests/workerd-test/asgi/worker.py +240 -0
  91. workers_runtime_sdk-1.6.7/tests/workerd-test/asgi/wrangler.jsonc +5 -0
  92. workers_runtime_sdk-1.6.7/tests/workerd-test/asgi-ws-disconnect/asgi-ws-disconnect.wd-test +19 -0
  93. workers_runtime_sdk-1.6.7/tests/workerd-test/asgi-ws-disconnect/pyproject.toml +5 -0
  94. workers_runtime_sdk-1.6.7/tests/workerd-test/asgi-ws-disconnect/tests/test_ws_disconnect.py +72 -0
  95. workers_runtime_sdk-1.6.7/tests/workerd-test/asgi-ws-disconnect/worker.py +70 -0
  96. workers_runtime_sdk-1.6.7/tests/workerd-test/asgi-ws-disconnect/wrangler.jsonc +5 -0
  97. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object/durable-object.wd-test +28 -0
  98. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object/pyproject.toml +5 -0
  99. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object/worker.py +144 -0
  100. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object/wrangler.jsonc +5 -0
  101. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-abort/durable-object-abort.wd-test +27 -0
  102. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-abort/pyproject.toml +5 -0
  103. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-abort/worker.py +57 -0
  104. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-abort/wrangler.jsonc +5 -0
  105. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-inheritance/durable-object-inheritance.wd-test +40 -0
  106. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-inheritance/pyproject.toml +5 -0
  107. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-inheritance/worker.py +115 -0
  108. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-inheritance/wrangler.jsonc +5 -0
  109. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-websocket/durable-object-websocket.wd-test +39 -0
  110. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-websocket/pyproject.toml +5 -0
  111. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-websocket/tester.js +27 -0
  112. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-websocket/worker.py +43 -0
  113. workers_runtime_sdk-1.6.7/tests/workerd-test/durable-object-websocket/wrangler.jsonc +5 -0
  114. workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/entropy-patches.wd-test +18 -0
  115. workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/pyproject.toml +18 -0
  116. workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/tests/test_aiohttp_websocket.py +7 -0
  117. workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/tests/test_langsmith.py +8 -0
  118. workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/tests/test_numpy.py +9 -0
  119. workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/tests/test_pydantic.py +8 -0
  120. workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/tests/test_rust_packages.py +10 -0
  121. workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/tests/test_ssl_avoidance.py +9 -0
  122. workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/worker.py +27 -0
  123. workers_runtime_sdk-1.6.7/tests/workerd-test/entropy-patches/wrangler.jsonc +5 -0
  124. workers_runtime_sdk-1.6.7/tests/workerd-test/python-rpc/pyproject.toml +5 -0
  125. workers_runtime_sdk-1.6.7/tests/workerd-test/python-rpc/python-rpc.wd-test +34 -0
  126. workers_runtime_sdk-1.6.7/tests/workerd-test/python-rpc/worker.js +101 -0
  127. workers_runtime_sdk-1.6.7/tests/workerd-test/python-rpc/worker.py +384 -0
  128. workers_runtime_sdk-1.6.7/tests/workerd-test/python-rpc/wrangler.jsonc +5 -0
  129. workers_runtime_sdk-1.6.7/tests/workerd-test/sdk/pyproject.toml +5 -0
  130. workers_runtime_sdk-1.6.7/tests/workerd-test/sdk/sdk.wd-test +42 -0
  131. workers_runtime_sdk-1.6.7/tests/workerd-test/sdk/server.py +35 -0
  132. workers_runtime_sdk-1.6.7/tests/workerd-test/sdk/tests/test_sdk.py +608 -0
  133. workers_runtime_sdk-1.6.7/tests/workerd-test/sdk/worker.py +71 -0
  134. workers_runtime_sdk-1.6.7/tests/workerd-test/sdk/wrangler.jsonc +5 -0
  135. workers_runtime_sdk-1.6.7/tests/workerd-test/wsgi/pyproject.toml +5 -0
  136. workers_runtime_sdk-1.6.7/tests/workerd-test/wsgi/worker.py +205 -0
  137. workers_runtime_sdk-1.6.7/tests/workerd-test/wsgi/wrangler.jsonc +5 -0
  138. workers_runtime_sdk-1.6.7/tests/workerd-test/wsgi/wsgi.wd-test +19 -0
  139. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/uv.lock +119 -1
  140. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/.gitignore +0 -0
  141. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/README.md +0 -0
  142. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/_cloudflare_compat_flags.pyi +0 -0
  143. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/_pyodide_entrypoint_helper.pyi +0 -0
  144. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/_workers_sdk_entropy_import_context.pth +0 -0
  145. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/_workers_sdk_entropy_import_context_loader.py +0 -0
  146. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/__init__.py +0 -0
  147. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/blob.py +0 -0
  148. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/entrypoints.py +0 -0
  149. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/fetch.py +0 -0
  150. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/formdata.py +0 -0
  151. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/py.typed +0 -0
  152. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/request.py +0 -0
  153. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/response.py +0 -0
  154. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/rpc.py +0 -0
  155. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/types.py +0 -0
  156. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/utils.py +0 -0
  157. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/workflows.py +0 -0
  158. {workers_runtime_sdk-1.6.5 → workers_runtime_sdk-1.6.7}/src/workers/wsgi.py +0 -0
@@ -20,4 +20,4 @@ This package provides utilities for:
20
20
  ## Testing
21
21
 
22
22
  - All the tests should be done inside `workerd`, not in the host environment.
23
- - Tests should be implemented in `../cli/tests` directory.
23
+ - Tests should be implemented in this package's `tests/` directory.
@@ -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.5
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.5"
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"]
@@ -93,14 +93,10 @@ def pydantic_core_context(module):
93
93
  with allow_bad_entropy_calls(1):
94
94
  yield
95
95
  finally:
96
- try:
97
- with allow_bad_entropy_calls(1):
98
- # validate_core_schema makes an ahash::AHashMap which makes
99
- # another entropy call for its hash seed. It will throw an error
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 = url.pathname
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,5 @@
1
+ [project]
2
+ name = "bindings-test"
3
+ version = "0.1.0"
4
+ requires-python = ">=3.12"
5
+ dependencies = ["pytest", "pytest-asyncio<1.2.0"]
@@ -0,0 +1,10 @@
1
+ # pyright: reportMissingImports=false
2
+
3
+ import pytest
4
+
5
+ from workers import env as _env
6
+
7
+
8
+ @pytest.fixture
9
+ def env():
10
+ return _env
@@ -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")