From 62df6e09383965040c0ac8e72c122b2ac72f72d9 Mon Sep 17 00:00:00 2001 From: Ville Brofeldt Date: Wed, 4 Sep 2024 18:15:41 +0000 Subject: [PATCH] fix side effect --- tests/unit_tests/jinja_context_test.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/unit_tests/jinja_context_test.py b/tests/unit_tests/jinja_context_test.py index 7dd32518ee283..6a3adbe0fd0c3 100644 --- a/tests/unit_tests/jinja_context_test.py +++ b/tests/unit_tests/jinja_context_test.py @@ -23,6 +23,7 @@ from pytest_mock import MockerFixture from sqlalchemy.dialects import mysql from sqlalchemy.dialects.postgresql import dialect +from sqlalchemy.orm.session import Session from superset import app from superset.commands.dataset.exceptions import DatasetNotFoundError @@ -846,7 +847,7 @@ def test_metric_macro_no_dataset_id_with_context_chart_no_datasource_id( ( [], {"target_type": "TIMESTAMP"}, - "postgresql://", + "postgresql://mydb", [{}], TimeFilter( from_expr=None, @@ -859,7 +860,7 @@ def test_metric_macro_no_dataset_id_with_context_chart_no_datasource_id( ( [], {"target_type": "TIMESTAMP"}, - "postgresql://", + "postgresql://mydb", [{"time_range": "Last week"}], TimeFilter( from_expr="TO_TIMESTAMP('2024-08-27 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US')", @@ -872,7 +873,7 @@ def test_metric_macro_no_dataset_id_with_context_chart_no_datasource_id( ( ["dttm"], {}, - "postgresql://", + "postgresql://mydb", [ { "filters": [ @@ -895,7 +896,7 @@ def test_metric_macro_no_dataset_id_with_context_chart_no_datasource_id( ( ["dt"], {"remove_filter": True}, - "postgresql://", + "postgresql://mydb", [ { "filters": [ @@ -918,7 +919,7 @@ def test_metric_macro_no_dataset_id_with_context_chart_no_datasource_id( ( ["dttm"], {"target_type": "DATE", "remove_filter": True}, - "trino://", + "trino://mydb", [ { "filters": [ @@ -948,6 +949,7 @@ def test_get_time_filter( time_filter: TimeFilter, removed_filters: list[str], applied_filters: list[str], + session: Session, ) -> None: """ Test the ``get_time_filter`` macro. @@ -964,6 +966,8 @@ def test_get_time_filter( main_dttm_col="dt", database=database, ) + session.add(database) + session.add(table) with ( freeze_time("2024-09-03"), @@ -979,3 +983,5 @@ def test_get_time_filter( assert cache.get_time_filter(*args, **kwargs) == time_filter assert cache.removed_filters == removed_filters assert cache.applied_filters == applied_filters + + session.rollback()