Esempio n. 1
0
def test_run():
    props = ["host", "port", "debug", "subprocess", "data_loader", "reaper_on"]
    with ExitStack() as stack:
        csv_path = "/../".join([os.path.dirname(__file__), "data/test_df.csv"])
        args = [
            "dtale.cli.py",
            "--host",
            "test",
            "--port",
            "9999",
            "--csv-path",
            csv_path,
            "--log-level",
            "info",
        ]
        stack.enter_context(mock.patch("sys.argv", args))
        mock_exit = stack.enter_context(mock.patch("sys.exit", mock.Mock()))
        mock_show = stack.enter_context(
            mock.patch("dtale.cli.script.show", mock.Mock()))
        run(script.main)
        mock_show.assert_called_once()
        _, kwargs = mock_show.call_args
        host, port, debug, subprocess, data_loader, reaper_on = map(
            kwargs.get, props)
        assert host == "test"
        assert not subprocess
        assert not debug
        assert port == 9999
        assert reaper_on
        assert data_loader is not None
        assert mock_exit.called_with(0)

    with ExitStack() as stack:
        csv_path = "/../".join([os.path.dirname(__file__), "data/test_df.csv"])
        args = [
            "dtale.cli.py",
            "--host",
            "test",
            "--port",
            "9999",
            "--csv-path",
            csv_path,
        ]
        stack.enter_context(mock.patch("sys.argv", args))
        mock_exit = stack.enter_context(mock.patch("sys.exit", mock.Mock()))
        mock_show = stack.enter_context(
            mock.patch("dtale.cli.script.show",
                       mock.Mock(side_effect=Exception())))
        run(script.main)
        mock_show.assert_called_once()
        _, kwargs = mock_show.call_args
        host, port, debug, subprocess, data_loader, reaper_on = map(
            kwargs.get, props)
        assert host == "test"
        assert not subprocess
        assert not debug
        assert port == 9999
        assert reaper_on
        assert data_loader is not None
        assert mock_exit.called_with(1)
Esempio n. 2
0
def test_run():
    props = ['host', 'port', 'debug', 'subprocess', 'data_loader', 'reaper_on']
    with ExitStack() as stack:
        csv_path = "/../".join([os.path.dirname(__file__), 'data/test_df.csv'])
        args = [
            'dtale.cli.py', '--host', 'test', '--port', '9999', '--csv-path',
            csv_path, '--log-level', 'info'
        ]
        stack.enter_context(mock.patch('sys.argv', args))
        mock_exit = stack.enter_context(mock.patch('sys.exit', mock.Mock()))
        mock_show = stack.enter_context(
            mock.patch('dtale.cli.script.show', mock.Mock()))
        run(script.main)
        mock_show.assert_called_once()
        _, kwargs = mock_show.call_args
        host, port, debug, subprocess, data_loader, reaper_on = map(
            kwargs.get, props)
        assert host == 'test'
        assert not subprocess
        assert not debug
        assert port == 9999
        assert reaper_on
        assert data_loader is not None
        assert mock_exit.called_with(0)

    with ExitStack() as stack:
        csv_path = "/../".join([os.path.dirname(__file__), 'data/test_df.csv'])
        args = [
            'dtale.cli.py', '--host', 'test', '--port', '9999', '--csv-path',
            csv_path
        ]
        stack.enter_context(mock.patch('sys.argv', args))
        mock_exit = stack.enter_context(mock.patch('sys.exit', mock.Mock()))
        mock_show = stack.enter_context(
            mock.patch('dtale.cli.script.show',
                       mock.Mock(side_effect=Exception())))
        run(script.main)
        mock_show.assert_called_once()
        _, kwargs = mock_show.call_args
        host, port, debug, subprocess, data_loader, reaper_on = map(
            kwargs.get, props)
        assert host == 'test'
        assert not subprocess
        assert not debug
        assert port == 9999
        assert reaper_on
        assert data_loader is not None
        assert mock_exit.called_with(1)
Esempio n. 3
0
    Runs a local server for the D-Tale application.

    This local server is recommended when you have a pandas object stored in a CSV
    or retrievable from :class:`arctic.Arctic` data store.
    """
    log_opts = get_log_options(kwargs)
    setup_logging(log_opts.get("logfile"), log_opts.get("log_level"),
                  log_opts.get("verbose"))

    data_loader = check_loaders(kwargs)

    # in order to handle the hierarchy of inputs if "--no-cell-edits" is not specified
    # then we'll update it to None
    allow_cell_edits = False if no_cell_edits is not None else None
    show(host=host,
         port=int(port or find_free_port()),
         debug=debug,
         subprocess=False,
         data_loader=data_loader,
         reaper_on=not no_reaper,
         open_browser=open_browser,
         name=name,
         allow_cell_edits=allow_cell_edits,
         hide_shutdown=hide_shutdown,
         github_fork=github_fork,
         **kwargs)


if __name__ == "__main__":
    run(main)