Skip to content

Commit

Permalink
Fix tests (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Sep 6, 2023
1 parent 810c22f commit db06d57
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 9 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ jobs:
channels: pyviz/label/dev,bokeh,conda-forge,nodefaults
envs: -o tests -o sql
cache: true
conda-mamba: mamba
id: install
- name: doit test_unit
run: |
Expand Down
27 changes: 25 additions & 2 deletions lumen/tests/sources/test_duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@
pytestmark = pytest.mark.skipif(DuckDBSource is None, reason="Duckdb is not installed")


def assert_frame_equal_ignore_null_like(a, b):
"""
From Pandas 2.1 we are getting this FutureWarning:
Mismatched null-like values nan and None found. In a future version,
pandas equality-testing functions (e.g. assert_frame_equal)
will consider these not-matching and raise.
Here we are converting all null-like values to np.nan.
Could be that in future release we get a keyword argument to ignore
this strict behavior
Reference: https://github.com/pandas-dev/pandas/pull/52081
"""
a = a.fillna(np.nan)
b = b.fillna(np.nan)
pd.testing.assert_frame_equal(a, b)


@pytest.fixture
def duckdb_source():
root = os.path.dirname(__file__)
Expand Down Expand Up @@ -43,7 +63,10 @@ def test_duckdb_get_tables(duckdb_source, source_tables):
tables = duckdb_source.get_tables()
assert not len(set(tables) - set(source_tables.keys()))
for table in tables:
pd.testing.assert_frame_equal(duckdb_source.get(table), source_tables[table])
assert_frame_equal_ignore_null_like(
duckdb_source.get(table),
source_tables[table],
)


def test_duckdb_get_schema(duckdb_source):
Expand Down Expand Up @@ -103,7 +126,7 @@ def test_duckdb_filter(duckdb_source, table_column_value_type, dask, expected_fi
table, column, value, _ = table_column_value_type
kwargs = {column: value}
filtered = duckdb_source.get(table, __dask=dask, **kwargs)
pd.testing.assert_frame_equal(filtered, expected_filtered_df.reset_index(drop=True))
assert_frame_equal_ignore_null_like(filtered, expected_filtered_df.reset_index(drop=True))


def test_duckdb_transforms(duckdb_source, source_tables):
Expand Down
12 changes: 12 additions & 0 deletions lumen/tests/ui/test_imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pathlib import Path

import pytest

ui_path = Path(__file__).parents[2] / "ui"
ui_files = sorted(ui_path.glob("[!_]*.py"))


@pytest.mark.parametrize("file", sorted(ui_files), ids=lambda f: f.name)
def test_ui_import(file) -> None:
module_name = file.with_suffix("").name
__import__(f"lumen.ui.{module_name}")
2 changes: 1 addition & 1 deletion lumen/tests/validation/test_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_layout_Facet(spec, msg):
),
(
{"format": "csvs"},
"Download component 'format' value failed validation: csvs",
"Download component 'format' value failed validation: .*?csvs",
),
),
ids=["correct1", "correct2", "wrong_format"],
Expand Down
4 changes: 2 additions & 2 deletions lumen/tests/validation/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
),
(
{"format": "csvs"},
"Download component 'format' value failed validation: csvs",
"Download component 'format' value failed validation: .*?csvs",
),
),
ids=["correct1", "correct2", "missing_required", "wrong_format"],
Expand Down Expand Up @@ -51,7 +51,7 @@ def test_target_Download(spec, output):
),
(
{"type": "download", "format": "csvs"},
"DownloadView component 'format' value failed validation: csvs",
"DownloadView component 'format' value failed validation: .*?csvs",
),
(
{"format": "csv"},
Expand Down
2 changes: 1 addition & 1 deletion lumen/ui/layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class LayoutsEditor(WizardItem):

title = param.String(default="")

spec = param.List(precedence=-1)
spec = param.List(allow_None=True, precedence=-1)

sources = param.List(doc="Select a source")

Expand Down
4 changes: 2 additions & 2 deletions lumen/ui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ViewsEditor(WizardItem):

pipelines = param.List(label='Select a pipeline')

views = param.List()
views = param.List(allow_None=True)

_template = """
<span style="font-size: 2em">View Editor</span>
Expand Down Expand Up @@ -202,7 +202,7 @@ class ViewGallery(WizardItem, Gallery):

path = param.Foldername()

spec = param.List()
spec = param.List(allow_None=True)

views = param.List(default=[], precedence=-1, doc="""
The list of views added to the dashboard.""")
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def get_setup_version(reponame):
'pytest-cov',
'codecov',
'pre-commit',
'matplotlib >=3.4', # Ubuntu + Python 3.9 installs old version matplotlib (3.3.2)
],
'doc': [
'nbsite >=0.8.2',
Expand Down

0 comments on commit db06d57

Please sign in to comment.