python-socketio 5.15.0__tar.gz → 5.15.1__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 (87) hide show
  1. {python_socketio-5.15.0/src/python_socketio.egg-info → python_socketio-5.15.1}/PKG-INFO +1 -1
  2. {python_socketio-5.15.0 → python_socketio-5.15.1}/pyproject.toml +1 -1
  3. {python_socketio-5.15.0 → python_socketio-5.15.1/src/python_socketio.egg-info}/PKG-INFO +1 -1
  4. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/async_pubsub_manager.py +9 -0
  5. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/pubsub_manager.py +9 -0
  6. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/async/test_pubsub_manager.py +207 -10
  7. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/common/test_pubsub_manager.py +197 -10
  8. {python_socketio-5.15.0 → python_socketio-5.15.1}/LICENSE +0 -0
  9. {python_socketio-5.15.0 → python_socketio-5.15.1}/MANIFEST.in +0 -0
  10. {python_socketio-5.15.0 → python_socketio-5.15.1}/README.md +0 -0
  11. {python_socketio-5.15.0 → python_socketio-5.15.1}/docs/Makefile +0 -0
  12. {python_socketio-5.15.0 → python_socketio-5.15.1}/docs/_static/README.md +0 -0
  13. {python_socketio-5.15.0 → python_socketio-5.15.1}/docs/_static/custom.css +0 -0
  14. {python_socketio-5.15.0 → python_socketio-5.15.1}/docs/api.rst +0 -0
  15. {python_socketio-5.15.0 → python_socketio-5.15.1}/docs/client.rst +0 -0
  16. {python_socketio-5.15.0 → python_socketio-5.15.1}/docs/conf.py +0 -0
  17. {python_socketio-5.15.0 → python_socketio-5.15.1}/docs/index.rst +0 -0
  18. {python_socketio-5.15.0 → python_socketio-5.15.1}/docs/intro.rst +0 -0
  19. {python_socketio-5.15.0 → python_socketio-5.15.1}/docs/make.bat +0 -0
  20. {python_socketio-5.15.0 → python_socketio-5.15.1}/docs/server.rst +0 -0
  21. {python_socketio-5.15.0 → python_socketio-5.15.1}/setup.cfg +0 -0
  22. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/python_socketio.egg-info/SOURCES.txt +0 -0
  23. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/python_socketio.egg-info/dependency_links.txt +0 -0
  24. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/python_socketio.egg-info/not-zip-safe +0 -0
  25. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/python_socketio.egg-info/requires.txt +0 -0
  26. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/python_socketio.egg-info/top_level.txt +0 -0
  27. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/__init__.py +0 -0
  28. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/admin.py +0 -0
  29. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/asgi.py +0 -0
  30. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/async_admin.py +0 -0
  31. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/async_aiopika_manager.py +0 -0
  32. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/async_client.py +0 -0
  33. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/async_manager.py +0 -0
  34. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/async_namespace.py +0 -0
  35. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/async_redis_manager.py +0 -0
  36. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/async_server.py +0 -0
  37. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/async_simple_client.py +0 -0
  38. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/base_client.py +0 -0
  39. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/base_manager.py +0 -0
  40. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/base_namespace.py +0 -0
  41. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/base_server.py +0 -0
  42. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/client.py +0 -0
  43. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/exceptions.py +0 -0
  44. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/kafka_manager.py +0 -0
  45. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/kombu_manager.py +0 -0
  46. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/manager.py +0 -0
  47. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/middleware.py +0 -0
  48. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/msgpack_packet.py +0 -0
  49. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/namespace.py +0 -0
  50. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/packet.py +0 -0
  51. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/redis_manager.py +0 -0
  52. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/server.py +0 -0
  53. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/simple_client.py +0 -0
  54. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/tornado.py +0 -0
  55. {python_socketio-5.15.0 → python_socketio-5.15.1}/src/socketio/zmq_manager.py +0 -0
  56. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/__init__.py +0 -0
  57. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/async/__init__.py +0 -0
  58. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/async/test_admin.py +0 -0
  59. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/async/test_client.py +0 -0
  60. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/async/test_manager.py +0 -0
  61. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/async/test_namespace.py +0 -0
  62. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/async/test_redis_manager.py +0 -0
  63. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/async/test_server.py +0 -0
  64. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/async/test_simple_client.py +0 -0
  65. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/asyncio_web_server.py +0 -0
  66. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/common/__init__.py +0 -0
  67. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/common/test_admin.py +0 -0
  68. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/common/test_client.py +0 -0
  69. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/common/test_manager.py +0 -0
  70. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/common/test_middleware.py +0 -0
  71. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/common/test_msgpack_packet.py +0 -0
  72. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/common/test_namespace.py +0 -0
  73. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/common/test_packet.py +0 -0
  74. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/common/test_redis_manager.py +0 -0
  75. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/common/test_server.py +0 -0
  76. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/common/test_simple_client.py +0 -0
  77. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/performance/README.md +0 -0
  78. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/performance/binary_packet.py +0 -0
  79. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/performance/json_packet.py +0 -0
  80. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/performance/namespace_packet.py +0 -0
  81. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/performance/run.sh +0 -0
  82. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/performance/server_receive.py +0 -0
  83. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/performance/server_send.py +0 -0
  84. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/performance/server_send_broadcast.py +0 -0
  85. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/performance/text_packet.py +0 -0
  86. {python_socketio-5.15.0 → python_socketio-5.15.1}/tests/web_server.py +0 -0
  87. {python_socketio-5.15.0 → python_socketio-5.15.1}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-socketio
3
- Version: 5.15.0
3
+ Version: 5.15.1
4
4
  Summary: Socket.IO server and client for Python
5
5
  Author-email: Miguel Grinberg <miguel.grinberg@gmail.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-socketio"
3
- version = "5.15.0"
3
+ version = "5.15.1"
4
4
  license = {text = "MIT"}
5
5
  authors = [
6
6
  { name = "Miguel Grinberg", email = "miguel.grinberg@gmail.com" },
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-socketio
3
- Version: 5.15.0
3
+ Version: 5.15.1
4
4
  Summary: Socket.IO server and client for Python
5
5
  Author-email: Miguel Grinberg <miguel.grinberg@gmail.com>
6
6
  License: MIT
@@ -66,6 +66,10 @@ class AsyncPubSubManager(AsyncManager):
66
66
  callback = (room, namespace, id)
67
67
  else:
68
68
  callback = None
69
+ if isinstance(data, tuple):
70
+ data = list(data)
71
+ else:
72
+ data = [data]
69
73
  binary = Packet.data_is_binary(data)
70
74
  if binary:
71
75
  data, attachments = Packet.deconstruct_binary(data)
@@ -155,6 +159,11 @@ class AsyncPubSubManager(AsyncManager):
155
159
  if message.get('binary'):
156
160
  attachments = [base64.b64decode(a) for a in data[1:]]
157
161
  data = Packet.reconstruct_binary(data[0], attachments)
162
+ if isinstance(data, list):
163
+ if len(data) == 1:
164
+ data = data[0]
165
+ else:
166
+ data = tuple(data)
158
167
  await super().emit(message['event'], data,
159
168
  namespace=message.get('namespace'),
160
169
  room=message.get('room'),
@@ -63,6 +63,10 @@ class PubSubManager(Manager):
63
63
  callback = (room, namespace, id)
64
64
  else:
65
65
  callback = None
66
+ if isinstance(data, tuple):
67
+ data = list(data)
68
+ else:
69
+ data = [data]
66
70
  binary = Packet.data_is_binary(data)
67
71
  if binary:
68
72
  data, attachments = Packet.deconstruct_binary(data)
@@ -151,6 +155,11 @@ class PubSubManager(Manager):
151
155
  if message.get('binary'):
152
156
  attachments = [base64.b64decode(a) for a in data[1:]]
153
157
  data = Packet.reconstruct_binary(data[0], attachments)
158
+ if isinstance(data, list):
159
+ if len(data) == 1:
160
+ data = data[0]
161
+ else:
162
+ data = tuple(data)
154
163
  super().emit(message['event'], data,
155
164
  namespace=message.get('namespace'),
156
165
  room=message.get('room'),
@@ -58,7 +58,7 @@ class TestAsyncPubSubManager:
58
58
  'method': 'emit',
59
59
  'event': 'foo',
60
60
  'binary': False,
61
- 'data': 'bar',
61
+ 'data': ['bar'],
62
62
  'namespace': '/',
63
63
  'room': None,
64
64
  'skip_sid': None,
@@ -74,7 +74,7 @@ class TestAsyncPubSubManager:
74
74
  'method': 'emit',
75
75
  'event': 'foo',
76
76
  'binary': True,
77
- 'data': [{'_placeholder': True, 'num': 0}, 'YmFy'],
77
+ 'data': [[{'_placeholder': True, 'num': 0}], 'YmFy'],
78
78
  'namespace': '/',
79
79
  'room': None,
80
80
  'skip_sid': None,
@@ -88,7 +88,7 @@ class TestAsyncPubSubManager:
88
88
  'method': 'emit',
89
89
  'event': 'foo',
90
90
  'binary': True,
91
- 'data': [{'foo': {'_placeholder': True, 'num': 0}}, 'YmFy'],
91
+ 'data': [[{'foo': {'_placeholder': True, 'num': 0}}], 'YmFy'],
92
92
  'namespace': '/',
93
93
  'room': None,
94
94
  'skip_sid': None,
@@ -104,7 +104,7 @@ class TestAsyncPubSubManager:
104
104
  'method': 'emit',
105
105
  'event': 'foo',
106
106
  'binary': True,
107
- 'data': [{'_placeholder': True, 'num': 0}, 'YmFy'],
107
+ 'data': [[{'_placeholder': True, 'num': 0}], 'YmFy'],
108
108
  'namespace': '/',
109
109
  'room': None,
110
110
  'skip_sid': None,
@@ -118,7 +118,87 @@ class TestAsyncPubSubManager:
118
118
  'method': 'emit',
119
119
  'event': 'foo',
120
120
  'binary': True,
121
- 'data': [{'foo': {'_placeholder': True, 'num': 0}}, 'YmFy'],
121
+ 'data': [[{'foo': {'_placeholder': True, 'num': 0}}], 'YmFy'],
122
+ 'namespace': '/',
123
+ 'room': None,
124
+ 'skip_sid': None,
125
+ 'callback': None,
126
+ 'host_id': '123456',
127
+ }
128
+ )
129
+
130
+ async def test_emit_list(self):
131
+ await self.pm.emit('foo', [1, 'two'])
132
+ self.pm._publish.assert_awaited_once_with(
133
+ {
134
+ 'method': 'emit',
135
+ 'event': 'foo',
136
+ 'binary': False,
137
+ 'data': [[1, 'two']],
138
+ 'namespace': '/',
139
+ 'room': None,
140
+ 'skip_sid': None,
141
+ 'callback': None,
142
+ 'host_id': '123456',
143
+ }
144
+ )
145
+ await self.pm.emit('foo', [1, b'two', 'three'])
146
+ self.pm._publish.assert_awaited_with(
147
+ {
148
+ 'method': 'emit',
149
+ 'event': 'foo',
150
+ 'binary': True,
151
+ 'data': [
152
+ [[1, {'_placeholder': True, 'num': 0}, 'three']], 'dHdv',
153
+ ],
154
+ 'namespace': '/',
155
+ 'room': None,
156
+ 'skip_sid': None,
157
+ 'callback': None,
158
+ 'host_id': '123456',
159
+ }
160
+ )
161
+
162
+ async def test_emit_no_arguments(self):
163
+ await self.pm.emit('foo', ())
164
+ self.pm._publish.assert_awaited_once_with(
165
+ {
166
+ 'method': 'emit',
167
+ 'event': 'foo',
168
+ 'binary': False,
169
+ 'data': [],
170
+ 'namespace': '/',
171
+ 'room': None,
172
+ 'skip_sid': None,
173
+ 'callback': None,
174
+ 'host_id': '123456',
175
+ }
176
+ )
177
+
178
+ async def test_emit_multiple_arguments(self):
179
+ await self.pm.emit('foo', (1, 'two'))
180
+ self.pm._publish.assert_awaited_once_with(
181
+ {
182
+ 'method': 'emit',
183
+ 'event': 'foo',
184
+ 'binary': False,
185
+ 'data': [1, 'two'],
186
+ 'namespace': '/',
187
+ 'room': None,
188
+ 'skip_sid': None,
189
+ 'callback': None,
190
+ 'host_id': '123456',
191
+ }
192
+ )
193
+ await self.pm.emit('foo', (1, b'two', 'three'))
194
+ self.pm._publish.assert_awaited_with(
195
+ {
196
+ 'method': 'emit',
197
+ 'event': 'foo',
198
+ 'binary': True,
199
+ 'data': [
200
+ [1, {'_placeholder': True, 'num': 0}, 'three'], 'dHdv',
201
+ ],
122
202
  'namespace': '/',
123
203
  'room': None,
124
204
  'skip_sid': None,
@@ -135,7 +215,7 @@ class TestAsyncPubSubManager:
135
215
  'method': 'emit',
136
216
  'event': 'foo',
137
217
  'binary': False,
138
- 'data': 'bar',
218
+ 'data': ['bar'],
139
219
  'namespace': '/',
140
220
  'room': sid,
141
221
  'skip_sid': None,
@@ -151,7 +231,7 @@ class TestAsyncPubSubManager:
151
231
  'method': 'emit',
152
232
  'event': 'foo',
153
233
  'binary': False,
154
- 'data': 'bar',
234
+ 'data': ['bar'],
155
235
  'namespace': '/baz',
156
236
  'room': None,
157
237
  'skip_sid': None,
@@ -167,7 +247,7 @@ class TestAsyncPubSubManager:
167
247
  'method': 'emit',
168
248
  'event': 'foo',
169
249
  'binary': False,
170
- 'data': 'bar',
250
+ 'data': ['bar'],
171
251
  'namespace': '/',
172
252
  'room': 'baz',
173
253
  'skip_sid': None,
@@ -183,7 +263,7 @@ class TestAsyncPubSubManager:
183
263
  'method': 'emit',
184
264
  'event': 'foo',
185
265
  'binary': False,
186
- 'data': 'bar',
266
+ 'data': ['bar'],
187
267
  'namespace': '/',
188
268
  'room': None,
189
269
  'skip_sid': 'baz',
@@ -202,7 +282,7 @@ class TestAsyncPubSubManager:
202
282
  'method': 'emit',
203
283
  'event': 'foo',
204
284
  'binary': False,
205
- 'data': 'bar',
285
+ 'data': ['bar'],
206
286
  'namespace': '/',
207
287
  'room': 'baz',
208
288
  'skip_sid': None,
@@ -294,6 +374,20 @@ class TestAsyncPubSubManager:
294
374
  )
295
375
 
296
376
  async def test_handle_emit(self):
377
+ with mock.patch.object(
378
+ async_manager.AsyncManager, 'emit'
379
+ ) as super_emit:
380
+ await self.pm._handle_emit({'event': 'foo', 'data': ['bar']})
381
+ super_emit.assert_awaited_once_with(
382
+ 'foo',
383
+ 'bar',
384
+ namespace=None,
385
+ room=None,
386
+ skip_sid=None,
387
+ callback=None,
388
+ )
389
+
390
+ async def test_handle_legacy_emit(self):
297
391
  with mock.patch.object(
298
392
  async_manager.AsyncManager, 'emit'
299
393
  ) as super_emit:
@@ -308,6 +402,37 @@ class TestAsyncPubSubManager:
308
402
  )
309
403
 
310
404
  async def test_handle_emit_binary(self):
405
+ with mock.patch.object(
406
+ async_manager.AsyncManager, 'emit'
407
+ ) as super_emit:
408
+ await self.pm._handle_emit({
409
+ 'event': 'foo',
410
+ 'binary': True,
411
+ 'data': [[{'_placeholder': True, 'num': 0}], 'YmFy'],
412
+ })
413
+ super_emit.assert_awaited_once_with(
414
+ 'foo',
415
+ b'bar',
416
+ namespace=None,
417
+ room=None,
418
+ skip_sid=None,
419
+ callback=None,
420
+ )
421
+ await self.pm._handle_emit({
422
+ 'event': 'foo',
423
+ 'binary': True,
424
+ 'data': [[{'foo': {'_placeholder': True, 'num': 0}}], 'YmFy'],
425
+ })
426
+ super_emit.assert_awaited_with(
427
+ 'foo',
428
+ {'foo': b'bar'},
429
+ namespace=None,
430
+ room=None,
431
+ skip_sid=None,
432
+ callback=None,
433
+ )
434
+
435
+ async def test_handle_legacy_emit_binary(self):
311
436
  with mock.patch.object(
312
437
  async_manager.AsyncManager, 'emit'
313
438
  ) as super_emit:
@@ -338,6 +463,78 @@ class TestAsyncPubSubManager:
338
463
  callback=None,
339
464
  )
340
465
 
466
+ async def test_handle_emit_list(self):
467
+ with mock.patch.object(
468
+ async_manager.AsyncManager, 'emit'
469
+ ) as super_emit:
470
+ await self.pm._handle_emit({'event': 'foo', 'data': [[1, 'two']]})
471
+ super_emit.assert_awaited_once_with(
472
+ 'foo',
473
+ [1, 'two'],
474
+ namespace=None,
475
+ room=None,
476
+ skip_sid=None,
477
+ callback=None,
478
+ )
479
+ await self.pm._handle_emit({
480
+ 'event': 'foo',
481
+ 'binary': True,
482
+ 'data': [
483
+ [[1, {'_placeholder': True, 'num': 0}, 'three']], 'dHdv'
484
+ ]
485
+ })
486
+ super_emit.assert_awaited_with(
487
+ 'foo',
488
+ [1, b'two', 'three'],
489
+ namespace=None,
490
+ room=None,
491
+ skip_sid=None,
492
+ callback=None,
493
+ )
494
+
495
+ async def test_handle_emit_no_arguments(self):
496
+ with mock.patch.object(
497
+ async_manager.AsyncManager, 'emit'
498
+ ) as super_emit:
499
+ await self.pm._handle_emit({'event': 'foo', 'data': []})
500
+ super_emit.assert_awaited_once_with(
501
+ 'foo',
502
+ (),
503
+ namespace=None,
504
+ room=None,
505
+ skip_sid=None,
506
+ callback=None,
507
+ )
508
+
509
+ async def test_handle_emit_multiple_arguments(self):
510
+ with mock.patch.object(
511
+ async_manager.AsyncManager, 'emit'
512
+ ) as super_emit:
513
+ await self.pm._handle_emit({'event': 'foo', 'data': [1, 'two']})
514
+ super_emit.assert_awaited_once_with(
515
+ 'foo',
516
+ (1, 'two'),
517
+ namespace=None,
518
+ room=None,
519
+ skip_sid=None,
520
+ callback=None,
521
+ )
522
+ await self.pm._handle_emit({
523
+ 'event': 'foo',
524
+ 'binary': True,
525
+ 'data': [
526
+ [1, {'_placeholder': True, 'num': 0}, 'three'], 'dHdv'
527
+ ]
528
+ })
529
+ super_emit.assert_awaited_with(
530
+ 'foo',
531
+ (1, b'two', 'three'),
532
+ namespace=None,
533
+ room=None,
534
+ skip_sid=None,
535
+ callback=None,
536
+ )
537
+
341
538
  async def test_handle_emit_with_namespace(self):
342
539
  with mock.patch.object(
343
540
  async_manager.AsyncManager, 'emit'
@@ -70,7 +70,7 @@ class TestPubSubManager:
70
70
  'method': 'emit',
71
71
  'event': 'foo',
72
72
  'binary': False,
73
- 'data': 'bar',
73
+ 'data': ['bar'],
74
74
  'namespace': '/',
75
75
  'room': None,
76
76
  'skip_sid': None,
@@ -86,7 +86,7 @@ class TestPubSubManager:
86
86
  'method': 'emit',
87
87
  'event': 'foo',
88
88
  'binary': True,
89
- 'data': [{'_placeholder': True, 'num': 0}, 'YmFy'],
89
+ 'data': [[{'_placeholder': True, 'num': 0}], 'YmFy'],
90
90
  'namespace': '/',
91
91
  'room': None,
92
92
  'skip_sid': None,
@@ -100,7 +100,7 @@ class TestPubSubManager:
100
100
  'method': 'emit',
101
101
  'event': 'foo',
102
102
  'binary': True,
103
- 'data': [{'foo': {'_placeholder': True, 'num': 0}}, 'YmFy'],
103
+ 'data': [[{'foo': {'_placeholder': True, 'num': 0}}], 'YmFy'],
104
104
  'namespace': '/',
105
105
  'room': None,
106
106
  'skip_sid': None,
@@ -116,7 +116,7 @@ class TestPubSubManager:
116
116
  'method': 'emit',
117
117
  'event': 'foo',
118
118
  'binary': True,
119
- 'data': [{'_placeholder': True, 'num': 0}, 'YmFy'],
119
+ 'data': [[{'_placeholder': True, 'num': 0}], 'YmFy'],
120
120
  'namespace': '/',
121
121
  'room': None,
122
122
  'skip_sid': None,
@@ -130,7 +130,87 @@ class TestPubSubManager:
130
130
  'method': 'emit',
131
131
  'event': 'foo',
132
132
  'binary': True,
133
- 'data': [{'foo': {'_placeholder': True, 'num': 0}}, 'YmFy'],
133
+ 'data': [[{'foo': {'_placeholder': True, 'num': 0}}], 'YmFy'],
134
+ 'namespace': '/',
135
+ 'room': None,
136
+ 'skip_sid': None,
137
+ 'callback': None,
138
+ 'host_id': '123456',
139
+ }
140
+ )
141
+
142
+ def test_emit_list(self):
143
+ self.pm.emit('foo', [1, 'two'])
144
+ self.pm._publish.assert_called_once_with(
145
+ {
146
+ 'method': 'emit',
147
+ 'event': 'foo',
148
+ 'binary': False,
149
+ 'data': [[1, 'two']],
150
+ 'namespace': '/',
151
+ 'room': None,
152
+ 'skip_sid': None,
153
+ 'callback': None,
154
+ 'host_id': '123456',
155
+ }
156
+ )
157
+ self.pm.emit('foo', [1, b'two', 'three'])
158
+ self.pm._publish.assert_called_with(
159
+ {
160
+ 'method': 'emit',
161
+ 'event': 'foo',
162
+ 'binary': True,
163
+ 'data': [
164
+ [[1, {'_placeholder': True, 'num': 0}, 'three']], 'dHdv',
165
+ ],
166
+ 'namespace': '/',
167
+ 'room': None,
168
+ 'skip_sid': None,
169
+ 'callback': None,
170
+ 'host_id': '123456',
171
+ }
172
+ )
173
+
174
+ def test_emit_no_arguments(self):
175
+ self.pm.emit('foo', ())
176
+ self.pm._publish.assert_called_once_with(
177
+ {
178
+ 'method': 'emit',
179
+ 'event': 'foo',
180
+ 'binary': False,
181
+ 'data': [],
182
+ 'namespace': '/',
183
+ 'room': None,
184
+ 'skip_sid': None,
185
+ 'callback': None,
186
+ 'host_id': '123456',
187
+ }
188
+ )
189
+
190
+ def test_emit_multiple_arguments(self):
191
+ self.pm.emit('foo', (1, 'two'))
192
+ self.pm._publish.assert_called_once_with(
193
+ {
194
+ 'method': 'emit',
195
+ 'event': 'foo',
196
+ 'binary': False,
197
+ 'data': [1, 'two'],
198
+ 'namespace': '/',
199
+ 'room': None,
200
+ 'skip_sid': None,
201
+ 'callback': None,
202
+ 'host_id': '123456',
203
+ }
204
+ )
205
+ self.pm.emit('foo', (1, b'two', 'three'))
206
+ self.pm._publish.assert_called_with(
207
+ {
208
+ 'method': 'emit',
209
+ 'event': 'foo',
210
+ 'binary': True,
211
+ 'data': [
212
+ [1, {'_placeholder': True, 'num': 0}, 'three'], 'dHdv',
213
+ ],
134
214
  'namespace': '/',
135
215
  'room': None,
136
216
  'skip_sid': None,
@@ -147,7 +227,7 @@ class TestPubSubManager:
147
227
  'method': 'emit',
148
228
  'event': 'foo',
149
229
  'binary': False,
150
- 'data': 'bar',
230
+ 'data': ['bar'],
151
231
  'namespace': '/',
152
232
  'room': sid,
153
233
  'skip_sid': None,
@@ -163,7 +243,7 @@ class TestPubSubManager:
163
243
  'method': 'emit',
164
244
  'event': 'foo',
165
245
  'binary': False,
166
- 'data': 'bar',
246
+ 'data': ['bar'],
167
247
  'namespace': '/baz',
168
248
  'room': None,
169
249
  'skip_sid': None,
@@ -179,7 +259,7 @@ class TestPubSubManager:
179
259
  'method': 'emit',
180
260
  'event': 'foo',
181
261
  'binary': False,
182
- 'data': 'bar',
262
+ 'data': ['bar'],
183
263
  'namespace': '/',
184
264
  'room': 'baz',
185
265
  'skip_sid': None,
@@ -195,7 +275,7 @@ class TestPubSubManager:
195
275
  'method': 'emit',
196
276
  'event': 'foo',
197
277
  'binary': False,
198
- 'data': 'bar',
278
+ 'data': ['bar'],
199
279
  'namespace': '/',
200
280
  'room': None,
201
281
  'skip_sid': 'baz',
@@ -214,7 +294,7 @@ class TestPubSubManager:
214
294
  'method': 'emit',
215
295
  'event': 'foo',
216
296
  'binary': False,
217
- 'data': 'bar',
297
+ 'data': ['bar'],
218
298
  'namespace': '/',
219
299
  'room': 'baz',
220
300
  'skip_sid': None,
@@ -305,6 +385,18 @@ class TestPubSubManager:
305
385
  )
306
386
 
307
387
  def test_handle_emit(self):
388
+ with mock.patch.object(manager.Manager, 'emit') as super_emit:
389
+ self.pm._handle_emit({'event': 'foo', 'data': ['bar']})
390
+ super_emit.assert_called_once_with(
391
+ 'foo',
392
+ 'bar',
393
+ namespace=None,
394
+ room=None,
395
+ skip_sid=None,
396
+ callback=None,
397
+ )
398
+
399
+ def test_handle_legacy_emit(self):
308
400
  with mock.patch.object(manager.Manager, 'emit') as super_emit:
309
401
  self.pm._handle_emit({'event': 'foo', 'data': 'bar'})
310
402
  super_emit.assert_called_once_with(
@@ -317,6 +409,35 @@ class TestPubSubManager:
317
409
  )
318
410
 
319
411
  def test_handle_emit_binary(self):
412
+ with mock.patch.object(manager.Manager, 'emit') as super_emit:
413
+ self.pm._handle_emit({
414
+ 'event': 'foo',
415
+ 'binary': True,
416
+ 'data': [[{'_placeholder': True, 'num': 0}], 'YmFy'],
417
+ })
418
+ super_emit.assert_called_once_with(
419
+ 'foo',
420
+ b'bar',
421
+ namespace=None,
422
+ room=None,
423
+ skip_sid=None,
424
+ callback=None,
425
+ )
426
+ self.pm._handle_emit({
427
+ 'event': 'foo',
428
+ 'binary': True,
429
+ 'data': [[{'foo': {'_placeholder': True, 'num': 0}}], 'YmFy'],
430
+ })
431
+ super_emit.assert_called_with(
432
+ 'foo',
433
+ {'foo': b'bar'},
434
+ namespace=None,
435
+ room=None,
436
+ skip_sid=None,
437
+ callback=None,
438
+ )
439
+
440
+ def test_handle_legacy_emit_binary(self):
320
441
  with mock.patch.object(manager.Manager, 'emit') as super_emit:
321
442
  self.pm._handle_emit({
322
443
  'event': 'foo',
@@ -345,6 +466,72 @@ class TestPubSubManager:
345
466
  callback=None,
346
467
  )
347
468
 
469
+ def test_handle_emit_list(self):
470
+ with mock.patch.object(manager.Manager, 'emit') as super_emit:
471
+ self.pm._handle_emit({'event': 'foo', 'data': [[1, 'two']]})
472
+ super_emit.assert_called_once_with(
473
+ 'foo',
474
+ [1, 'two'],
475
+ namespace=None,
476
+ room=None,
477
+ skip_sid=None,
478
+ callback=None,
479
+ )
480
+ self.pm._handle_emit({
481
+ 'event': 'foo',
482
+ 'binary': True,
483
+ 'data': [
484
+ [[1, {'_placeholder': True, 'num': 0}, 'three']], 'dHdv'
485
+ ],
486
+ })
487
+ super_emit.assert_called_with(
488
+ 'foo',
489
+ [1, b'two', 'three'],
490
+ namespace=None,
491
+ room=None,
492
+ skip_sid=None,
493
+ callback=None,
494
+ )
495
+
496
+ def test_handle_emit_no_arguments(self):
497
+ with mock.patch.object(manager.Manager, 'emit') as super_emit:
498
+ self.pm._handle_emit({'event': 'foo', 'data': []})
499
+ super_emit.assert_called_once_with(
500
+ 'foo',
501
+ (),
502
+ namespace=None,
503
+ room=None,
504
+ skip_sid=None,
505
+ callback=None,
506
+ )
507
+
508
+ def test_handle_emit_multiple_arguments(self):
509
+ with mock.patch.object(manager.Manager, 'emit') as super_emit:
510
+ self.pm._handle_emit({'event': 'foo', 'data': [1, 'two']})
511
+ super_emit.assert_called_once_with(
512
+ 'foo',
513
+ (1, 'two'),
514
+ namespace=None,
515
+ room=None,
516
+ skip_sid=None,
517
+ callback=None,
518
+ )
519
+ self.pm._handle_emit({
520
+ 'event': 'foo',
521
+ 'binary': True,
522
+ 'data': [
523
+ [1, {'_placeholder': True, 'num': 0}, 'three'], 'dHdv'
524
+ ],
525
+ })
526
+ super_emit.assert_called_with(
527
+ 'foo',
528
+ (1, b'two', 'three'),
529
+ namespace=None,
530
+ room=None,
531
+ skip_sid=None,
532
+ callback=None,
533
+ )
534
+
348
535
  def test_handle_emit_with_namespace(self):
349
536
  with mock.patch.object(manager.Manager, 'emit') as super_emit:
350
537
  self.pm._handle_emit(