Skip to content

Commit

Permalink
fix side effect
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Sep 4, 2024
1 parent 3ea3530 commit a3fbd5d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/unit_tests/jinja_context_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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')",
Expand All @@ -872,7 +873,7 @@ def test_metric_macro_no_dataset_id_with_context_chart_no_datasource_id(
(
["dttm"],
{},
"postgresql://",
"postgresql://mydb",
[
{
"filters": [
Expand All @@ -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": [
Expand All @@ -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": [
Expand Down Expand Up @@ -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.
Expand All @@ -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"),
Expand All @@ -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()

0 comments on commit a3fbd5d

Please sign in to comment.