def test_build_startup_url_and_app_root(): from dtale.app import build_startup_url_and_app_root with ExitStack() as stack: stack.enter_context(mock.patch("dtale.app.JUPYTER_SERVER_PROXY", True)) stack.enter_context(mock.patch("dtale.app.ACTIVE_PORT", 40000)) stack.enter_context(mock.patch("dtale.app.ACTIVE_HOST", "localhost")) url, app_root = build_startup_url_and_app_root() assert url == "/user/{}/proxy/40000".format(getpass.getuser()) assert app_root == "/user/{}/proxy/40000".format(getpass.getuser()) url, app_root = build_startup_url_and_app_root("/test_route/") assert url == "/test_route/40000" assert app_root == "/test_route/40000" with ExitStack() as stack: stack.enter_context(mock.patch("dtale.app.JUPYTER_SERVER_PROXY", False)) stack.enter_context(mock.patch("dtale.app.ACTIVE_PORT", 40000)) stack.enter_context(mock.patch("dtale.app.ACTIVE_HOST", "localhost")) url, app_root = build_startup_url_and_app_root() assert url == "http://localhost:40000" assert app_root is None url, app_root = build_startup_url_and_app_root("/test_route/") assert url == "http:/localhost:40000/test_route/" assert app_root == "/test_route/"
def test_build_startup_url_and_app_root(): from dtale.app import build_startup_url_and_app_root with ExitStack() as stack: stack.enter_context(mock.patch('dtale.app.JUPYTER_SERVER_PROXY', True)) stack.enter_context(mock.patch('dtale.app.ACTIVE_PORT', 40000)) stack.enter_context(mock.patch('dtale.app.ACTIVE_HOST', 'localhost')) url, app_root = build_startup_url_and_app_root() assert url == '/user/{}/proxy/40000'.format(getpass.getuser()) assert app_root == '/user/{}/proxy/40000'.format(getpass.getuser()) url, app_root = build_startup_url_and_app_root('/test_route/') assert url == '/test_route/40000' assert app_root == '/test_route/40000' with ExitStack() as stack: stack.enter_context(mock.patch('dtale.app.JUPYTER_SERVER_PROXY', False)) stack.enter_context(mock.patch('dtale.app.ACTIVE_PORT', 40000)) stack.enter_context(mock.patch('dtale.app.ACTIVE_HOST', 'localhost')) url, app_root = build_startup_url_and_app_root() assert url == 'http://localhost:40000' assert app_root is None url, app_root = build_startup_url_and_app_root('/test_route/') assert url == 'http:/localhost:40000/test_route/' assert app_root == '/test_route/'