Skip to content

Commit

Permalink
add typing to fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
Stan Houcke committed Dec 7, 2022
1 parent c9ff9fb commit 92df588
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions tests/unit_tests/commands/importers/v1/assets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,25 @@
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:
"""
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions tests/unit_tests/fixtures/assets_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down

0 comments on commit 92df588

Please sign in to comment.