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.
Files changed (66) hide show
  1. {chanx-2.2.0 → chanx-2.2.2}/PKG-INFO +1 -1
  2. {chanx-2.2.0 → chanx-2.2.2}/chanx/core/testing.py +13 -3
  3. {chanx-2.2.0 → chanx-2.2.2}/pyproject.toml +1 -1
  4. {chanx-2.2.0 → chanx-2.2.2}/.gitignore +0 -0
  5. {chanx-2.2.0 → chanx-2.2.2}/AUTHORS.rst +0 -0
  6. {chanx-2.2.0 → chanx-2.2.2}/LICENSE +0 -0
  7. {chanx-2.2.0 → chanx-2.2.2}/README.rst +0 -0
  8. {chanx-2.2.0 → chanx-2.2.2}/chanx/__init__.py +0 -0
  9. {chanx-2.2.0 → chanx-2.2.2}/chanx/asyncapi/__init__.py +0 -0
  10. {chanx-2.2.0 → chanx-2.2.2}/chanx/asyncapi/constants.py +0 -0
  11. {chanx-2.2.0 → chanx-2.2.2}/chanx/asyncapi/generator.py +0 -0
  12. {chanx-2.2.0 → chanx-2.2.2}/chanx/asyncapi/type_defs.py +0 -0
  13. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/__init__.py +0 -0
  14. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/apps.py +0 -0
  15. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/authenticator.py +0 -0
  16. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/discovery.py +0 -0
  17. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/routing.py +0 -0
  18. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/settings.py +0 -0
  19. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/templates/channels/asyncapi_docs.html +0 -0
  20. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/testing.py +0 -0
  21. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/urls.py +0 -0
  22. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/utils/__init__.py +0 -0
  23. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/utils/asgi.py +0 -0
  24. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/utils/request.py +0 -0
  25. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/utils/settings.py +0 -0
  26. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/views.py +0 -0
  27. {chanx-2.2.0 → chanx-2.2.2}/chanx/channels/websocket.py +0 -0
  28. {chanx-2.2.0 → chanx-2.2.2}/chanx/cli/__init__.py +0 -0
  29. {chanx-2.2.0 → chanx-2.2.2}/chanx/cli/main.py +0 -0
  30. {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/__init__.py +0 -0
  31. {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/analyzer.py +0 -0
  32. {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/base/__init__.py +0 -0
  33. {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/base/client.py +0 -0
  34. {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/codegen.py +0 -0
  35. {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/generator.py +0 -0
  36. {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/loader.py +0 -0
  37. {chanx-2.2.0 → chanx-2.2.2}/chanx/client_generator/templates.py +0 -0
  38. {chanx-2.2.0 → chanx-2.2.2}/chanx/constants.py +0 -0
  39. {chanx-2.2.0 → chanx-2.2.2}/chanx/core/__init__.py +0 -0
  40. {chanx-2.2.0 → chanx-2.2.2}/chanx/core/authenticator.py +0 -0
  41. {chanx-2.2.0 → chanx-2.2.2}/chanx/core/check.py +0 -0
  42. {chanx-2.2.0 → chanx-2.2.2}/chanx/core/config.py +0 -0
  43. {chanx-2.2.0 → chanx-2.2.2}/chanx/core/decorators.py +0 -0
  44. {chanx-2.2.0 → chanx-2.2.2}/chanx/core/registry.py +0 -0
  45. {chanx-2.2.0 → chanx-2.2.2}/chanx/core/websocket.py +0 -0
  46. {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/__init__.py +0 -0
  47. {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/constants.py +0 -0
  48. {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/discovery.py +0 -0
  49. {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/testing.py +0 -0
  50. {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/type_defs.py +0 -0
  51. {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/utils.py +0 -0
  52. {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/views.py +0 -0
  53. {chanx-2.2.0 → chanx-2.2.2}/chanx/fast_channels/websocket.py +0 -0
  54. {chanx-2.2.0 → chanx-2.2.2}/chanx/messages/__init__.py +0 -0
  55. {chanx-2.2.0 → chanx-2.2.2}/chanx/messages/base.py +0 -0
  56. {chanx-2.2.0 → chanx-2.2.2}/chanx/messages/incoming.py +0 -0
  57. {chanx-2.2.0 → chanx-2.2.2}/chanx/messages/outgoing.py +0 -0
  58. {chanx-2.2.0 → chanx-2.2.2}/chanx/py.typed +0 -0
  59. {chanx-2.2.0 → chanx-2.2.2}/chanx/routing/__init__.py +0 -0
  60. {chanx-2.2.0 → chanx-2.2.2}/chanx/routing/discovery.py +0 -0
  61. {chanx-2.2.0 → chanx-2.2.2}/chanx/routing/patterns.py +0 -0
  62. {chanx-2.2.0 → chanx-2.2.2}/chanx/routing/traversal.py +0 -0
  63. {chanx-2.2.0 → chanx-2.2.2}/chanx/type_defs.py +0 -0
  64. {chanx-2.2.0 → chanx-2.2.2}/chanx/utils/__init__.py +0 -0
  65. {chanx-2.2.0 → chanx-2.2.2}/chanx/utils/asyncio.py +0 -0
  66. {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.0
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, TypedDict, cast
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
- class CapturedBroadcastEvent(TypedDict):
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
- await original_broadcast_event(event, groups)
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]
@@ -106,7 +106,7 @@ license = {file = "LICENSE"}
106
106
  name = "chanx"
107
107
  readme = "README.rst"
108
108
  requires-python = ">=3.11,<4.0"
109
- version = "2.2.0"
109
+ version = "2.2.2"
110
110
 
111
111
  [project.optional-dependencies]
112
112
  channels = [
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