From 817a34b5471e0be9dc4532832c89231a61108466 Mon Sep 17 00:00:00 2001 From: Cor Zuurmond Date: Fri, 21 Jun 2024 10:43:47 +0200 Subject: [PATCH] Test filter widget attribute --- tests/unit/test_dashboards.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/unit/test_dashboards.py b/tests/unit/test_dashboards.py index 9e89f155..941e5c7b 100644 --- a/tests/unit/test_dashboards.py +++ b/tests/unit/test_dashboards.py @@ -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)