File tree 2 files changed +23
-3
lines changed
2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -147,10 +147,13 @@ class BaseChannelLayer(ABC):
147
147
148
148
MAX_NAME_LENGTH = 100
149
149
extensions : Iterable [str ] = ()
150
+ expiry : int
151
+ capacity : int
152
+ channel_capacity : Dict [str , int ]
150
153
151
154
def __init__ (
152
155
self ,
153
- expiry = 60 ,
156
+ expiry : int = 60 ,
154
157
capacity : Optional [int ] = 100 ,
155
158
channel_capacity : Optional [int ] = None ,
156
159
):
@@ -263,7 +266,12 @@ async def new_channel(self, prefix: str = "specific.") -> str:
263
266
"""
264
267
265
268
266
- class InMemoryChannelLayer (WithFlushExtension , WithGroupsExtension , BaseChannelLayer ):
269
+ # WARNING: Protocols must be last
270
+ class InMemoryChannelLayer (
271
+ BaseChannelLayer ,
272
+ WithFlushExtension ,
273
+ WithGroupsExtension ,
274
+ ):
267
275
"""
268
276
In-memory channel layer implementation
269
277
"""
Original file line number Diff line number Diff line change 13
13
)
14
14
15
15
16
+ # when starting with Test it would be tried to collect by pytest
17
+ class StubChannelLayer (BaseChannelLayer ):
18
+ async def send (self , channel : str , message : dict ):
19
+ raise NotImplementedError ()
20
+
21
+ async def receive (self , channel : str ) -> dict :
22
+ raise NotImplementedError ()
23
+
24
+ async def new_channel (self , prefix : str = "specific." ) -> str :
25
+ raise NotImplementedError ()
26
+
27
+
16
28
class TestChannelLayerManager (unittest .TestCase ):
17
29
@override_settings (
18
30
CHANNEL_LAYERS = {"default" : {"BACKEND" : "channels.layers.InMemoryChannelLayer" }}
@@ -72,7 +84,7 @@ async def test_send_receive():
72
84
73
85
@pytest .mark .parametrize (
74
86
"method" ,
75
- [BaseChannelLayer ().valid_channel_name , BaseChannelLayer ().valid_group_name ],
87
+ [StubChannelLayer ().valid_channel_name , StubChannelLayer ().valid_group_name ],
76
88
)
77
89
@pytest .mark .parametrize (
78
90
"channel_name,expected_valid" ,
You can’t perform that action at this time.
0 commit comments