Skip to content

Commit

Permalink
Test filter widget attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
JCZuurmond committed Jun 21, 2024
1 parent 810eded commit 817a34b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/unit/test_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,25 @@ def test_dashboard_creates_dashboard_with_description(tmp_path):
ws.assert_not_called()


def test_dashboard_creates_dashboard_with_filter(tmp_path):
ws = create_autospec(WorkspaceClient)

filter_column = "City"
query = f"-- --filter {filter_column}\nSELECT Address, City, Province, Country FROM europe"
(tmp_path / "table.sql").write_text(query)

lakeview_dashboard = Dashboards(ws).create_dashboard(tmp_path)

layouts = lakeview_dashboard.pages[0].layout
assert any(f"filter_{filter_column}" in layout.widget.name for layout in layouts)
filter_query = [layout.widget for layout in layouts if filter_column in layout.widget.name][0].queries[0]
assert filter_query.name == f"filter_{filter_column}"
assert len(filter_query.query.fields) == 2
assert filter_query.query.fields[0].name == filter_column # Filter column
assert filter_column in filter_query.query.fields[1].name # Associativity column
ws.assert_not_called()


def test_dashboard_handles_incorrect_query_header(tmp_path, caplog):
ws = create_autospec(WorkspaceClient)

Expand Down

0 comments on commit 817a34b

Please sign in to comment.