Esempio n. 1
0
def test_convert():
    from dtale.views import startup
    from tests.dtale.test_replacements import replacements_data

    with app.test_client() as c:
        with ExitStack() as stack:
            data, dtypes, datasets, dataset_dim, settings = {}, {}, {}, {}, {}
            stack.enter_context(mock.patch("dtale.global_state.DATA", data))
            stack.enter_context(mock.patch("dtale.global_state.DTYPES",
                                           dtypes))
            stack.enter_context(
                mock.patch("dtale.global_state.DATASETS", datasets))
            stack.enter_context(
                mock.patch("dtale.global_state.DATASET_DIM", dataset_dim))
            stack.enter_context(
                mock.patch("dtale.global_state.SETTINGS", settings))
            startup(URL, data=replacements_data(), data_id=c.port)

            resp = c.get(
                "/dtale/to-xarray/{}".format(c.port),
                query_string=dict(index=json.dumps(["a"])),
            )
            assert resp.status_code == 200
            assert c.port in datasets
            assert settings[c.port]["locked"] == ["a"]
Esempio n. 2
0
def test_convert():
    from dtale.views import startup
    from tests.dtale.test_replacements import replacements_data
    import dtale.global_state as global_state

    global_state.clear_store()
    with app.test_client() as c:
        global_state.new_data_inst(c.port)
        startup(URL, data=replacements_data(), data_id=c.port)

        resp = c.get(
            "/dtale/to-xarray/{}".format(c.port),
            query_string=dict(index=json.dumps(["a"])),
        )
        assert resp.status_code == 200
        assert global_state.get_dataset(c.port) is not None
        assert global_state.get_settings(c.port)["locked"] == ["a"]