Skip to content

Commit

Permalink
Rewrite test to test find fields directly
Browse files Browse the repository at this point in the history
  • Loading branch information
JCZuurmond committed Jun 17, 2024
1 parent 29efa7c commit f9aff18
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions tests/unit/test_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
DashboardMetadata,
Dashboards,
WidgetMetadata,
QueryTile,
Tile,
)
from databricks.labs.lsql.lakeview import (
Expand Down Expand Up @@ -298,16 +299,10 @@ def test_dashboards_does_not_create_widget_for_yml_file(tmp_path, caplog):
("SELECT from_unixtime(timestamp) AS timestamp FROM table", ["timestamp"]),
],
)
def test_dashboards_gets_fields_with_expected_names(tmp_path, query, names):
with (tmp_path / "query.sql").open("w") as f:
f.write(query)

ws = create_autospec(WorkspaceClient)
lakeview_dashboard = Dashboards(ws).create_dashboard(tmp_path)

fields = lakeview_dashboard.pages[0].layout[0].widget.queries[0].query.fields
def test_query_tile_finds_fields(query, names):
tile = QueryTile("test", "test")
fields = tile.find_fields(query)
assert [field.name for field in fields] == names
ws.assert_not_called()


def test_dashboards_creates_dashboard_with_expected_counter_field_encoding_names(tmp_path):
Expand Down

0 comments on commit f9aff18

Please sign in to comment.