Browse Source

rebase

pull/1422/head
Miguel Grinberg 4 months ago
parent
commit
93da325534
Failed to extract signature
  1. 2
      src/socketio/async_server.py
  2. 2
      src/socketio/server.py
  3. 10
      tests/async/test_namespace.py
  4. 3
      tests/async/test_server.py
  5. 1
      tests/common/test_namespace.py
  6. 3
      tests/common/test_server.py

2
src/socketio/async_server.py

@ -584,7 +584,7 @@ class AsyncServer(base_server.BaseServer):
return
self.manager.pre_disconnect(sid, namespace=namespace)
await self._trigger_event('disconnect', namespace, sid,
reason or self.reason.UNKNOWN)
reason or self.reason.CLIENT_DISCONNECT)
await self.manager.disconnect(sid, namespace, ignore_queue=True)
async def _handle_event(self, eio_sid, namespace, id, data):

2
src/socketio/server.py

@ -566,7 +566,7 @@ class Server(base_server.BaseServer):
return
self.manager.pre_disconnect(sid, namespace=namespace)
self._trigger_event('disconnect', namespace, sid,
reason or self.reason.UNKNOWN)
reason or self.reason.CLIENT_DISCONNECT)
self.manager.disconnect(sid, namespace, ignore_queue=True)
def _handle_event(self, eio_sid, namespace, id, data):

10
tests/async/test_namespace.py

@ -25,10 +25,10 @@ class TestAsyncNamespace:
ns = MyNamespace('/foo')
ns._set_server(mock.MagicMock())
_run(ns.trigger_event('disconnect', 'sid', 'foo'))
await ns.trigger_event('disconnect', 'sid', 'foo')
assert result['result'] == ('sid', 'foo')
def test_legacy_disconnect_event(self):
async def test_legacy_disconnect_event(self):
result = {}
class MyNamespace(async_namespace.AsyncNamespace):
@ -37,10 +37,10 @@ class TestAsyncNamespace:
ns = MyNamespace('/foo')
ns._set_server(mock.MagicMock())
_run(ns.trigger_event('disconnect', 'sid', 'foo'))
await ns.trigger_event('disconnect', 'sid', 'foo')
assert result['result'] == 'sid'
def test_legacy_disconnect_event_async(self):
async def test_legacy_disconnect_event_async(self):
result = {}
class MyNamespace(async_namespace.AsyncNamespace):
@ -266,7 +266,7 @@ class TestAsyncNamespace:
await ns.disconnect('sid', namespace='/bar')
ns.server.disconnect.assert_awaited_with('sid', namespace='/bar')
async def test_disconnect_event(self):
async def test_disconnect_event_client(self):
result = {}
class MyNamespace(async_namespace.AsyncClientNamespace):

3
tests/async/test_server.py

@ -653,7 +653,8 @@ class TestAsyncServer:
await s._handle_eio_message('123', '2/bar,["msg","a","b"]')
await s._handle_eio_message('123', '2/foo,["my message","a","b","c"]')
await s._handle_eio_message('123', '2/bar,["my message","a","b","c"]')
await s._trigger_event('disconnect', '/bar', sid_bar, s.reason.UNKNOWN)
await s._trigger_event('disconnect', '/bar', sid_bar,
s.reason.CLIENT_DISCONNECT)
connect_star_handler.assert_called_once_with('/bar', sid_bar)
msg_foo_handler.assert_called_once_with(sid_foo, 'a', 'b')
msg_star_handler.assert_called_once_with('/bar', sid_bar, 'a', 'b')

1
tests/common/test_namespace.py

@ -252,7 +252,6 @@ class TestNamespace:
ns.trigger_event('disconnect', 'foo')
assert result['result'] == 'ok'
def test_event_not_found_client(self):
result = {}

3
tests/common/test_server.py

@ -610,7 +610,8 @@ class TestServer:
s._handle_eio_message('123', '2/bar,["msg","a","b"]')
s._handle_eio_message('123', '2/foo,["my message","a","b","c"]')
s._handle_eio_message('123', '2/bar,["my message","a","b","c"]')
s._trigger_event('disconnect', '/bar', sid_bar, s.reason.UNKNOWN)
s._trigger_event('disconnect', '/bar', sid_bar,
s.reason.CLIENT_DISCONNECT)
connect_star_handler.assert_called_once_with('/bar', sid_bar)
msg_foo_handler.assert_called_once_with(sid_foo, 'a', 'b')
msg_star_handler.assert_called_once_with('/bar', sid_bar, 'a', 'b')

Loading…
Cancel
Save