Ejemplo n.º 1
0
 def test_enable_devtools(
     self,
     mock_listener: mock.Mock,
     mock_executor_pool: mock.Mock,
     mock_acceptor_pool: mock.Mock,
     mock_event_manager: mock.Mock,
     mock_parse_args: mock.Mock,
     mock_load_plugins: mock.Mock,
     mock_sleep: mock.Mock,
 ) -> None:
     mock_sleep.side_effect = KeyboardInterrupt()
     mock_args = mock_parse_args.return_value
     self.mock_default_args(mock_args)
     mock_args.enable_devtools = True
     mock_args.local_executor = 0
     main(enable_devtools=True, local_executor=0)
     mock_load_plugins.assert_called()
     self.assertEqual(
         mock_load_plugins.call_args_list[0][0][0],
         [
             bytes_(PLUGIN_DEVTOOLS_PROTOCOL),
             bytes_(PLUGIN_WEB_SERVER),
             bytes_(PLUGIN_HTTP_PROXY),
         ],
     )
     mock_parse_args.assert_called_once()
     # Currently --enable-devtools flag alone doesn't enable eventing core
     mock_event_manager.assert_not_called()
     if _env_threadless_compliant():
         mock_executor_pool.assert_called_once()
         mock_executor_pool.return_value.setup.assert_called_once()
     mock_acceptor_pool.assert_called_once()
     mock_acceptor_pool.return_value.setup.assert_called_once()
     mock_listener.return_value.setup.assert_called_once()
Ejemplo n.º 2
0
 def test_enable_ssh_tunnel(
     self,
     mock_ssh_tunnel_listener: mock.Mock,
     mock_ssh_http_proto_handler: mock.Mock,
     mock_listener: mock.Mock,
     mock_executor_pool: mock.Mock,
     mock_acceptor_pool: mock.Mock,
     mock_event_manager: mock.Mock,
     mock_parse_args: mock.Mock,
     mock_load_plugins: mock.Mock,
     mock_sleep: mock.Mock,
 ) -> None:
     mock_sleep.side_effect = KeyboardInterrupt()
     mock_args = mock_parse_args.return_value
     self.mock_default_args(mock_args)
     mock_args.enable_ssh_tunnel = True
     mock_args.local_executor = 0
     main(enable_ssh_tunnel=True, local_executor=0)
     mock_load_plugins.assert_called()
     self.assertEqual(
         mock_load_plugins.call_args_list[0][0][0],
         [
             bytes_(PLUGIN_HTTP_PROXY),
         ],
     )
     mock_parse_args.assert_called_once()
     mock_event_manager.assert_not_called()
     if _env_threadless_compliant():
         mock_executor_pool.assert_called_once()
         mock_executor_pool.return_value.setup.assert_called_once()
     mock_acceptor_pool.assert_called_once()
     mock_acceptor_pool.return_value.setup.assert_called_once()
     mock_listener.return_value.setup.assert_called_once()
     mock_ssh_http_proto_handler.assert_called_once()
     mock_ssh_tunnel_listener.assert_called_once()
     mock_ssh_tunnel_listener.return_value.setup.assert_called_once()
     mock_ssh_tunnel_listener.return_value.start_port_forward.assert_called_once(
     )
     mock_ssh_tunnel_listener.return_value.shutdown.assert_called_once()
     # shutdown will internally call stop port forward
     mock_ssh_tunnel_listener.return_value.stop_port_forward.assert_not_called(
     )
Ejemplo n.º 3
0
 def test_enable_dashboard(
     self,
     mock_listener: mock.Mock,
     mock_executor_pool: mock.Mock,
     mock_acceptor_pool: mock.Mock,
     mock_event_manager: mock.Mock,
     mock_parse_args: mock.Mock,
     mock_load_plugins: mock.Mock,
     mock_sleep: mock.Mock,
 ) -> None:
     mock_sleep.side_effect = KeyboardInterrupt()
     mock_args = mock_parse_args.return_value
     self.mock_default_args(mock_args)
     mock_args.enable_dashboard = True
     mock_args.local_executor = 0
     main(enable_dashboard=True, local_executor=0)
     mock_load_plugins.assert_called()
     self.assertEqual(
         mock_load_plugins.call_args_list[0][0][0],
         [
             bytes_(PLUGIN_WEB_SERVER),
             bytes_(PLUGIN_DASHBOARD),
             bytes_(PLUGIN_WEBSOCKET_TRANSPORT),
             bytes_(PLUGIN_INSPECT_TRAFFIC),
             bytes_(PLUGIN_DEVTOOLS_PROTOCOL),
             bytes_(PLUGIN_HTTP_PROXY),
         ],
     )
     # TODO: Assert arguments passed to parse_arg
     mock_parse_args.assert_called_once()
     # dashboard will also enable eventing
     mock_event_manager.assert_called_once()
     mock_event_manager.return_value.setup.assert_called_once()
     mock_event_manager.return_value.shutdown.assert_called_once()
     if _env_threadless_compliant():
         mock_executor_pool.assert_called_once()
         mock_executor_pool.return_value.setup.assert_called_once()
     mock_acceptor_pool.assert_called_once()
     mock_acceptor_pool.return_value.setup.assert_called_once()
     mock_listener.return_value.setup.assert_called_once()