MCPcopy Create free account
hub / github.com/miguelgrinberg/python-socketio / test_disconnect

Method test_disconnect

tests/async/test_client.py:516–534  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

514 )
515
516 async def test_disconnect(self):
517 c = async_client.AsyncClient()
518 c.connected = True
519 c.namespaces = {'/': '1'}
520 c._trigger_event = mock.AsyncMock()
521 c._send_packet = mock.AsyncMock()
522 c.eio = mock.MagicMock()
523 c.eio.disconnect = mock.AsyncMock()
524 c.eio.state = 'connected'
525 await c.disconnect()
526 assert c.connected
527 assert c._trigger_event.await_count == 0
528 assert c._send_packet.await_count == 1
529 expected_packet = packet.Packet(packet.DISCONNECT, namespace='/')
530 assert (
531 c._send_packet.await_args_list[0][0][0].encode()
532 == expected_packet.encode()
533 )
534 c.eio.disconnect.assert_awaited_once_with()
535
536 async def test_disconnect_namespaces(self):
537 c = async_client.AsyncClient()

Callers

nothing calls this directly

Calls 2

disconnectMethod · 0.95
encodeMethod · 0.95

Tested by

no test coverage detected