chanx 2.2.0__tar.gz → 2.2.2__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.
- {chanx-2.2.0 → chanx-2.2.2}/PKG-INFO +1 -1
- {chanx-2.2.0 → chanx-2.2.2}/chanx/core/testing.py +13 -3
- {chanx-2.2.0 → chanx-2.2.2}/pyproject.toml +1 -1
- {chanx-2.2.0 → chanx-2.2.2}/.gitignore +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/AUTHORS.rst +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/LICENSE +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/README.rst +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/__init__.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/asyncapi/__init__.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/asyncapi/constants.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/asyncapi/generator.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/asyncapi/type_defs.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/__init__.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/apps.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/authenticator.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/discovery.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/routing.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/settings.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/templates/channels/asyncapi_docs.html +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/testing.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/urls.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/utils/__init__.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/utils/asgi.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/utils/request.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/utils/settings.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/views.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/websocket.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/cli/__init__.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/cli/main.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/__init__.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/analyzer.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/base/__init__.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/base/client.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/codegen.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/generator.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/loader.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/templates.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/constants.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/core/__init__.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/core/authenticator.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/core/check.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/core/config.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/core/decorators.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/core/registry.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/core/websocket.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/__init__.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/constants.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/discovery.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/testing.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/type_defs.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/utils.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/views.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/websocket.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/messages/__init__.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/messages/base.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/messages/incoming.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/messages/outgoing.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/py.typed +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/routing/__init__.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/routing/discovery.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/routing/patterns.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/routing/traversal.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/type_defs.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/utils/__init__.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/utils/asyncio.py +0 -0
- {chanx-2.2.0 → chanx-2.2.2}/chanx/utils/logging.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chanx
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.2
|
|
4
4
|
Summary: The missing toolkit for Channels — auth, logging, consumers, and more.
|
|
5
5
|
Project-URL: Documentation, https://chanx.readthedocs.io/
|
|
6
6
|
Project-URL: Homepage, https://github.com/huynguyengl99/chanx
|
|
@@ -13,8 +13,9 @@ fast-channels, etc.) to create concrete testing utilities.
|
|
|
13
13
|
import asyncio
|
|
14
14
|
from collections.abc import Collection, Generator
|
|
15
15
|
from contextlib import contextmanager
|
|
16
|
+
from dataclasses import dataclass
|
|
16
17
|
from types import TracebackType
|
|
17
|
-
from typing import Any, Self,
|
|
18
|
+
from typing import Any, Self, cast
|
|
18
19
|
|
|
19
20
|
import humps
|
|
20
21
|
from asgiref.timeout import timeout as async_timeout
|
|
@@ -29,7 +30,8 @@ from chanx.core.websocket import ChanxWebsocketConsumerMixin
|
|
|
29
30
|
from chanx.messages.base import BaseMessage
|
|
30
31
|
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
@dataclass
|
|
34
|
+
class CapturedBroadcastEvent:
|
|
33
35
|
"""Structure of a captured broadcast event."""
|
|
34
36
|
|
|
35
37
|
event: BaseMessage
|
|
@@ -267,6 +269,7 @@ class WebsocketCommunicatorMixin:
|
|
|
267
269
|
@contextmanager
|
|
268
270
|
def capture_broadcast_events(
|
|
269
271
|
consumer: type[ChanxWebsocketConsumerMixin],
|
|
272
|
+
suppress: bool = True,
|
|
270
273
|
) -> Generator[list[CapturedBroadcastEvent], None, None]:
|
|
271
274
|
"""
|
|
272
275
|
Capture broadcast events sent via broadcast_event() for testing purposes.
|
|
@@ -274,6 +277,11 @@ def capture_broadcast_events(
|
|
|
274
277
|
Similar to structlog's capture_logs(), this context manager captures calls to
|
|
275
278
|
broadcast_event() by monkey-patching the broadcast_event method to spy on events.
|
|
276
279
|
|
|
280
|
+
Args:
|
|
281
|
+
consumer: The consumer class to capture broadcast events from.
|
|
282
|
+
suppress: If True (default), suppress actual broadcast event calls.
|
|
283
|
+
If False, capture events and still call the original broadcast_event.
|
|
284
|
+
|
|
277
285
|
Returns:
|
|
278
286
|
A list that will be populated with captured broadcast events.
|
|
279
287
|
"""
|
|
@@ -298,7 +306,9 @@ def capture_broadcast_events(
|
|
|
298
306
|
)
|
|
299
307
|
)
|
|
300
308
|
|
|
301
|
-
|
|
309
|
+
# Only call original if not suppressing
|
|
310
|
+
if not suppress:
|
|
311
|
+
await original_broadcast_event(event, groups)
|
|
302
312
|
|
|
303
313
|
# Monkey-patch the method
|
|
304
314
|
consumer.broadcast_event = classmethod(capture_wrapper) # type: ignore[method-assign, assignment]
|
|
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
|