Esempio n. 1
0
 def _instance_msgs():
     for data_id in global_state.keys():
         data_obj = DtaleData(data_id, build_url(ACTIVE_PORT, ACTIVE_HOST))
         name = global_state.get_name(data_id)
         yield [data_id, name or "", data_obj.build_main_url(data_id=data_id)]
         if name is not None:
             yield [
                 global_state.convert_name_to_url_path(name),
                 name,
                 data_obj.build_main_url(),
             ]
Esempio n. 2
0
 def _instance_msgs():
     for data_id in global_state.keys():
         startup_url, final_app_root = build_startup_url_and_app_root()
         instance = DtaleData(
             data_id,
             startup_url,
             is_proxy=JUPYTER_SERVER_PROXY,
             app_root=final_app_root,
         )
         name = global_state.get_name(data_id)
         yield [data_id, name or "", instance.build_main_url()]
         if name is not None:
             yield [
                 global_state.convert_name_to_url_path(name),
                 name,
                 instance.build_main_url(),
             ]
Esempio n. 3
0
def test_jupyter_server_proxy_is_proxy():
    from dtale.views import DtaleData

    with ExitStack() as stack:
        stack.enter_context(mock.patch("dtale.app.ACTIVE_HOST", "foo"))
        stack.enter_context(mock.patch("dtale.app.ACTIVE_PORT", 40000))
        stack.enter_context(mock.patch("dtale.app.JUPYTER_SERVER_PROXY", True))
        stack.enter_context(
            mock.patch("dtale.views.in_ipython_frontend", return_value=True)
        )
        mock_requests = stack.enter_context(mock.patch("requests.get", mock.Mock()))
        instance = DtaleData(
            9999,
            "user/root/proxy/40000",
            is_proxy=True,
            app_root="user/root/proxy/40000",
        )
        assert instance.build_main_url() == "user/root/proxy/40000/dtale/main/9999"
        instance.kill()
        mock_requests.assert_called_once_with("http://foo:40000/shutdown")