From 92df588befb158e090ae2c525df0636d52f09a7b Mon Sep 17 00:00:00 2001 From: Stan Houcke Date: Wed, 7 Dec 2022 09:34:07 +0000 Subject: [PATCH] add typing to fixture --- .../unit_tests/commands/importers/v1/assets_test.py | 13 +++++++------ tests/unit_tests/fixtures/assets_configs.py | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/unit_tests/commands/importers/v1/assets_test.py b/tests/unit_tests/commands/importers/v1/assets_test.py index e8b650a64cbf1..1a345ff2b913b 100644 --- a/tests/unit_tests/commands/importers/v1/assets_test.py +++ b/tests/unit_tests/commands/importers/v1/assets_test.py @@ -18,15 +18,16 @@ import copy from sqlalchemy.orm.session import Session +from sqlalchemy.sql import select + from tests.unit_tests.fixtures.assets_configs import ( - databases_config, - datasets_config, charts_config_1, charts_config_2, dashboards_config_1, dashboards_config_2, + databases_config, + datasets_config, ) -from sqlalchemy.sql import select def test_import_new_assets(session: Session) -> None: @@ -34,8 +35,8 @@ def test_import_new_assets(session: Session) -> None: Test that all new assets are imported correctly. """ from superset.commands.importers.v1.assets import ImportAssetsCommand - from superset.models.slice import Slice from superset.models.dashboard import dashboard_slices + from superset.models.slice import Slice engine = session.get_bind() Slice.metadata.create_all(engine) # pylint: disable=no-member @@ -63,8 +64,8 @@ def test_import_adds_dashboard_charts(session: Session) -> None: Test that existing dashboards are updated with new charts. """ from superset.commands.importers.v1.assets import ImportAssetsCommand - from superset.models.slice import Slice from superset.models.dashboard import dashboard_slices + from superset.models.slice import Slice engine = session.get_bind() Slice.metadata.create_all(engine) # pylint: disable=no-member @@ -99,8 +100,8 @@ def test_import_removes_dashboard_charts(session: Session) -> None: Test that existing dashboards are updated without old charts. """ from superset.commands.importers.v1.assets import ImportAssetsCommand - from superset.models.slice import Slice from superset.models.dashboard import dashboard_slices + from superset.models.slice import Slice engine = session.get_bind() Slice.metadata.create_all(engine) # pylint: disable=no-member diff --git a/tests/unit_tests/fixtures/assets_configs.py b/tests/unit_tests/fixtures/assets_configs.py index 759b4a2ee4040..14ff37cf6153d 100644 --- a/tests/unit_tests/fixtures/assets_configs.py +++ b/tests/unit_tests/fixtures/assets_configs.py @@ -14,8 +14,9 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +from typing import Any, Dict -databases_config = { +databases_config: Dict[str, Any] = { "databases/examples.yaml": { "database_name": "examples", "sqlalchemy_uri": "sqlite:///test.db", @@ -31,7 +32,7 @@ "allow_csv_upload": False, }, } -datasets_config = { +datasets_config: Dict[str, Any] = { "datasets/examples/video_game_sales.yaml": { "table_name": "video_game_sales", "main_dttm_col": None, @@ -79,7 +80,7 @@ "database_uuid": "a2dc77af-e654-49bb-b321-40f6b559a1ee", }, } -charts_config_1 = { +charts_config_1: Dict[str, Any] = { "charts/Games_per_Genre_over_time_95.yaml": { "slice_name": "Games per Genre over time", "viz_type": "line", @@ -99,7 +100,7 @@ "dataset_uuid": "53d47c0c-c03d-47f0-b9ac-81225f808283", }, } -dashboards_config_1 = { +dashboards_config_1: Dict[str, Any] = { "dashboards/Video_Game_Sales_11.yaml": { "dashboard_title": "Video Game Sales", "description": None, @@ -181,7 +182,7 @@ }, } -charts_config_2 = { +charts_config_2: Dict[str, Any] = { "charts/Games_per_Genre_131.yaml": { "slice_name": "Games per Genre", "viz_type": "treemap", @@ -192,7 +193,7 @@ "dataset_uuid": "53d47c0c-c03d-47f0-b9ac-81225f808283", }, } -dashboards_config_2 = { +dashboards_config_2: Dict[str, Any] = { "dashboards/Video_Game_Sales_11.yaml": { "dashboard_title": "Video Game Sales", "description": None,