def test_handle_connect_namespace_rejected_with_empty_exception(self, eio):
     s = server.Server()
     handler = mock.MagicMock(
         side_effect=exceptions.ConnectionRefusedError())
     s.on('connect', handler, namespace='/foo')
     s._handle_eio_connect('123', 'environ')
     s._handle_eio_message('123', '0/foo')
     assert not s.manager.is_connected('1', '/foo')
     s.eio.send.assert_called_once_with('123', '4/foo')
     assert s.environ == {'123': 'environ'}
Exemple #2
0
 def test_handle_connect_namespace_rejected_with_exception(self, eio):
     mgr = mock.MagicMock()
     s = server.Server(client_manager=mgr)
     handler = mock.MagicMock(
         side_effect=exceptions.ConnectionRefusedError(u'fail_reason'))
     s.on('connect', handler, namespace='/foo')
     s._handle_eio_connect('123', 'environ')
     s._handle_eio_message('123', '0/foo')
     self.assertEqual(s.manager.connect.call_count, 2)
     self.assertEqual(s.manager.disconnect.call_count, 1)
     s.eio.send.assert_any_call('123', '4/foo,"fail_reason"', binary=False)
Exemple #3
0
 def test_handle_connect_rejected_with_exception(self, eio):
     s = server.Server()
     handler = mock.MagicMock(
         side_effect=exceptions.ConnectionRefusedError('fail_reason'))
     s.on('connect', handler)
     s._handle_eio_connect('123', 'environ')
     s._handle_eio_message('123', '0')
     assert not s.manager.is_connected('1', '/')
     handler.assert_called_once_with('1', 'environ')
     s.eio.send.assert_called_once_with('123', '4{"message":"fail_reason"}')
     assert s.environ == {'123': 'environ'}
Exemple #4
0
 def test_handle_connect_rejected_with_exception(self, eio):
     mgr = mock.MagicMock()
     s = server.Server(client_manager=mgr)
     handler = mock.MagicMock(
         side_effect=exceptions.ConnectionRefusedError())
     s.on('connect', handler)
     s._handle_eio_connect('123', 'environ')
     handler.assert_called_once_with('123', 'environ')
     self.assertEqual(s.manager.connect.call_count, 1)
     self.assertEqual(s.manager.disconnect.call_count, 1)
     self.assertEqual(s.environ, {})
     s.eio.send.assert_any_call('123', '4', binary=False)
 def test_handle_connect_rejected_with_exception(self, eio):
     eio.return_value.send = AsyncMock()
     mgr = self._get_mock_manager()
     s = asyncio_server.AsyncServer(client_manager=mgr)
     handler = mock.MagicMock(
         side_effect=exceptions.ConnectionRefusedError('fail_reason'))
     s.on('connect', handler)
     _run(s._handle_eio_connect('123', 'environ'))
     self.assertEqual(s.manager.connect.call_count, 1)
     self.assertEqual(s.manager.disconnect.call_count, 1)
     self.assertEqual(s.environ, {})
     s.eio.send.mock.assert_any_call('123', '4"fail_reason"', binary=False)
Exemple #6
0
 def test_handle_connect_rejected_with_empty_exception(self, eio):
     eio.return_value.send = AsyncMock()
     mgr = self._get_mock_manager()
     s = asyncio_server.AsyncServer(client_manager=mgr)
     handler = mock.MagicMock(
         side_effect=exceptions.ConnectionRefusedError())
     s.on('connect', handler)
     ret = _run(s._handle_eio_connect('123', 'environ'))
     assert not ret
     assert s.manager.connect.call_count == 1
     assert s.manager.disconnect.call_count == 1
     assert s.environ == {}
Exemple #7
0
 def test_handle_connect_rejected_with_empty_exception(self, eio):
     mgr = mock.MagicMock()
     s = server.Server(client_manager=mgr)
     handler = mock.MagicMock(
         side_effect=exceptions.ConnectionRefusedError())
     s.on('connect', handler)
     ret = s._handle_eio_connect('123', 'environ')
     assert not ret
     handler.assert_called_once_with('123', 'environ')
     assert s.manager.connect.call_count == 1
     assert s.manager.disconnect.call_count == 1
     assert s.environ == {}
Exemple #8
0
 def test_handle_connect_rejected_with_empty_exception(self, eio):
     eio.return_value.send = AsyncMock()
     s = asyncio_server.AsyncServer()
     handler = mock.MagicMock(
         side_effect=exceptions.ConnectionRefusedError())
     s.on('connect', handler)
     _run(s._handle_eio_connect('123', 'environ'))
     _run(s._handle_eio_message('123', '0'))
     assert not s.manager.is_connected('1', '/')
     handler.assert_called_once_with('1', 'environ')
     s.eio.send.mock.assert_called_once_with('123', '4')
     assert s.environ == {'123': 'environ'}
Exemple #9
0
 def test_handle_connect_namespace_rejected_with_exception(self, eio):
     eio.return_value.send = AsyncMock()
     s = asyncio_server.AsyncServer()
     handler = mock.MagicMock(side_effect=exceptions.ConnectionRefusedError(
         'fail_reason', 1, '2'))
     s.on('connect', handler, namespace='/foo')
     _run(s._handle_eio_connect('123', 'environ'))
     _run(s._handle_eio_message('123', '0/foo,'))
     assert not s.manager.is_connected('1', '/foo')
     handler.assert_called_once_with('1', 'environ')
     s.eio.send.mock.assert_called_once_with(
         '123', '4/foo,{"message":"fail_reason","data":[1,"2"]}')
     assert s.environ == {'123': 'environ'}
Exemple #10
0
 def test_handle_connect_namespace_rejected_with_empty_exception(self, eio):
     mgr = mock.MagicMock()
     s = server.Server(client_manager=mgr)
     handler = mock.MagicMock(
         side_effect=exceptions.ConnectionRefusedError())
     s.on('connect', handler, namespace='/foo')
     ret = s._handle_eio_connect('123', 'environ')
     s._handle_eio_message('123', '0/foo')
     assert ret is None
     assert s.manager.connect.call_count == 2
     assert s.manager.disconnect.call_count == 1
     assert s.environ == {'123': 'environ'}
     s.eio.send.assert_any_call('123', '4/foo', binary=False)
 def test_handle_connect_namespace_rejected_with_empty_exception(self, eio):
     eio.return_value.send = AsyncMock()
     mgr = self._get_mock_manager()
     s = asyncio_server.AsyncServer(client_manager=mgr)
     handler = mock.MagicMock(
         side_effect=exceptions.ConnectionRefusedError())
     s.on('connect', handler, namespace='/foo')
     ret = _run(s._handle_eio_connect('123', 'environ'))
     _run(s._handle_eio_message('123', '0/foo'))
     self.assertIsNone(ret)
     self.assertEqual(s.manager.connect.call_count, 2)
     self.assertEqual(s.manager.disconnect.call_count, 1)
     self.assertEqual(s.environ, {'123': 'environ'})
     s.eio.send.mock.assert_any_call('123', '4/foo', binary=False)
Exemple #12
0
 def test_handle_connect_namespace_rejected_with_exception(self, eio):
     eio.return_value.send = AsyncMock()
     mgr = self._get_mock_manager()
     s = asyncio_server.AsyncServer(client_manager=mgr)
     handler = mock.MagicMock(
         side_effect=exceptions.ConnectionRefusedError('fail_reason', 1))
     s.on('connect', handler, namespace='/foo')
     ret = _run(s._handle_eio_connect('123', 'environ'))
     _run(s._handle_eio_message('123', '0/foo'))
     assert ret is None
     assert s.manager.connect.call_count == 2
     assert s.manager.disconnect.call_count == 1
     assert s.environ == {'123': 'environ'}
     s.eio.send.mock.assert_any_call('123',
                                     '4/foo,["fail_reason",1]',
                                     binary=False)