Skip to content

Commit

Permalink
Merge pull request #10 from phillipdupuis/feature/unpin-dtale
Browse files Browse the repository at this point in the history
Updated dtale requirement so new versions can be used
  • Loading branch information
phillipdupuis authored Feb 3, 2021
2 parents c3994c8 + 1c7abb8 commit b2356f9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 2 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def readme():
]

install_requires = [
"dtale==1.22.1", # unpin this in the future
"dtale>=1.22.1", # Earlier versions probably also work, just need to figure out how far back...
"fastapi",
"uvicorn[standard]",
"aiofiles",
Expand All @@ -29,7 +29,7 @@ def readme():

setup(
name="dtaledesktop",
version="0.0.15",
version="0.1.0",
description="Build a data visualization dashboard with simple snippets of python code",
license="MIT",
long_description=readme(),
Expand Down
66 changes: 66 additions & 0 deletions tests/test_dtale_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import pandas as pd
import pytest


@pytest.fixture
def dtale_app(monkeypatch, tmpdir):
"""
Sets environment variables before importing the app.
"""
monkeypatch.setenv("DTALEDESKTOP_ROOT_DIR", tmpdir.strpath)
monkeypatch.setenv("DTALEDESKTOP_HOST", "localhost")
monkeypatch.setenv("DTALEDESKTOP_DTALE_PORT", "54321")

from dtale_desktop import dtale_app as _dtale_app

return _dtale_app


@pytest.fixture
def data():
return pd.DataFrame([{"a": 1, "b": 2, "c": 3}])


@pytest.fixture
def data_id():
return "abc123"


def test_launch_instance(dtale_app, data, data_id):
instance = dtale_app.launch_instance(data=data, data_id=data_id)
assert instance.is_up()
assert (
instance.main_url()
== f"{dtale_app.DTALE_EXTERNAL_ROOT_URL}/dtale/main/{data_id}"
)
pd.testing.assert_frame_equal(data, instance.data)


def test_get_instance(dtale_app, data, data_id):
_ = dtale_app.launch_instance(data=data, data_id=data_id)
instance = dtale_app.get_instance(data_id)
pd.testing.assert_frame_equal(data, instance.data)


def test_urls_valid(dtale_app, data, data_id):
instance = dtale_app.launch_instance(data=data, data_id=data_id)
main_url = dtale_app.get_main_url(data_id)
charts_url = dtale_app.get_charts_url(data_id)
describe_url = dtale_app.get_describe_url(data_id)
correlations_url = dtale_app.get_correlations_url(data_id)

assert main_url == instance.main_url()

with dtale_app.app.test_client(port=54321) as c:
for url in (main_url, charts_url, describe_url, correlations_url):
assert c.get(url).status_code == 200


def test_kill_instance(dtale_app, data, data_id):
with dtale_app.app.test_client(port=54321) as c:
dtale_app.launch_instance(data=data, data_id=data_id)
main_url = dtale_app.get_main_url(data_id)
assert c.get(main_url).status_code == 200

dtale_app.kill_instance(data_id)
assert c.get(main_url).status_code != 200

0 comments on commit b2356f9

Please sign in to comment.