From 739018630afa188706da5e780a7ab96defc45353 Mon Sep 17 00:00:00 2001 From: AAfghahi Date: Thu, 17 Nov 2022 14:05:53 -0500 Subject: [PATCH] added fixtures --- tests/integration_tests/charts/data/api_tests.py | 7 ++++++- tests/integration_tests/fixtures/energy_dashboard.py | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/integration_tests/charts/data/api_tests.py b/tests/integration_tests/charts/data/api_tests.py index 4aba5b2e22975..fe304d339244b 100644 --- a/tests/integration_tests/charts/data/api_tests.py +++ b/tests/integration_tests/charts/data/api_tests.py @@ -38,8 +38,12 @@ load_birth_names_data, ) from tests.integration_tests.test_app import app - +from tests.integration_tests.fixtures.energy_dashboard import ( + load_energy_table_with_slice, + load_energy_table_data, +) import pytest +from superset.models.slice import Slice from superset.charts.data.commands.get_data_command import ChartDataCommand from superset.connectors.sqla.models import TableColumn, SqlaTable @@ -1027,6 +1031,7 @@ def test_data_cache_default_timeout( def test_chart_cache_timeout( + test_client, login_as_admin, physical_query_context, load_energy_table_with_slice: List[Slice], diff --git a/tests/integration_tests/fixtures/energy_dashboard.py b/tests/integration_tests/fixtures/energy_dashboard.py index c0291db2a9864..c2f82b10463d9 100644 --- a/tests/integration_tests/fixtures/energy_dashboard.py +++ b/tests/integration_tests/fixtures/energy_dashboard.py @@ -52,15 +52,15 @@ def load_energy_table_data(): ) yield with app.app_context(): - engine = get_example_database().get_sqla_engine() - engine.execute("DROP TABLE IF EXISTS energy_usage") + with get_example_database().get_sqla_engine_with_context() as engine: + engine.execute("DROP TABLE IF EXISTS energy_usage") @pytest.fixture() def load_energy_table_with_slice(load_energy_table_data): with app.app_context(): - _create_energy_table() - yield + slices = _create_energy_table() + yield slices _cleanup()