-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into chore/bump-pillow-lib
- Loading branch information
Showing
8 changed files
with
463 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import copy | ||
|
||
from sqlalchemy.orm.session import Session | ||
from sqlalchemy.sql import select | ||
|
||
from tests.unit_tests.fixtures.assets_configs import ( | ||
charts_config_1, | ||
charts_config_2, | ||
dashboards_config_1, | ||
dashboards_config_2, | ||
databases_config, | ||
datasets_config, | ||
) | ||
|
||
|
||
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.dashboard import dashboard_slices | ||
from superset.models.slice import Slice | ||
|
||
engine = session.get_bind() | ||
Slice.metadata.create_all(engine) # pylint: disable=no-member | ||
configs = { | ||
**copy.deepcopy(databases_config), | ||
**copy.deepcopy(datasets_config), | ||
**copy.deepcopy(charts_config_1), | ||
**copy.deepcopy(dashboards_config_1), | ||
} | ||
expected_number_of_dashboards = len(dashboards_config_1) | ||
expected_number_of_charts = len(charts_config_1) | ||
|
||
ImportAssetsCommand._import(session, configs) | ||
dashboard_ids = session.scalars( | ||
select(dashboard_slices.c.dashboard_id).distinct() | ||
).all() | ||
chart_ids = session.scalars(select(dashboard_slices.c.slice_id)).all() | ||
|
||
assert len(chart_ids) == expected_number_of_charts | ||
assert len(dashboard_ids) == expected_number_of_dashboards | ||
|
||
|
||
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.dashboard import dashboard_slices | ||
from superset.models.slice import Slice | ||
|
||
engine = session.get_bind() | ||
Slice.metadata.create_all(engine) # pylint: disable=no-member | ||
base_configs = { | ||
**copy.deepcopy(databases_config), | ||
**copy.deepcopy(datasets_config), | ||
**copy.deepcopy(charts_config_2), | ||
**copy.deepcopy(dashboards_config_2), | ||
} | ||
new_configs = { | ||
**copy.deepcopy(databases_config), | ||
**copy.deepcopy(datasets_config), | ||
**copy.deepcopy(charts_config_1), | ||
**copy.deepcopy(dashboards_config_1), | ||
} | ||
expected_number_of_dashboards = len(dashboards_config_1) | ||
expected_number_of_charts = len(charts_config_1) | ||
|
||
ImportAssetsCommand._import(session, base_configs) | ||
ImportAssetsCommand._import(session, new_configs) | ||
dashboard_ids = session.scalars( | ||
select(dashboard_slices.c.dashboard_id).distinct() | ||
).all() | ||
chart_ids = session.scalars(select(dashboard_slices.c.slice_id)).all() | ||
|
||
assert len(chart_ids) == expected_number_of_charts | ||
assert len(dashboard_ids) == expected_number_of_dashboards | ||
|
||
|
||
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.dashboard import dashboard_slices | ||
from superset.models.slice import Slice | ||
|
||
engine = session.get_bind() | ||
Slice.metadata.create_all(engine) # pylint: disable=no-member | ||
base_configs = { | ||
**copy.deepcopy(databases_config), | ||
**copy.deepcopy(datasets_config), | ||
**copy.deepcopy(charts_config_1), | ||
**copy.deepcopy(dashboards_config_1), | ||
} | ||
new_configs = { | ||
**copy.deepcopy(databases_config), | ||
**copy.deepcopy(datasets_config), | ||
**copy.deepcopy(charts_config_2), | ||
**copy.deepcopy(dashboards_config_2), | ||
} | ||
expected_number_of_dashboards = len(dashboards_config_2) | ||
expected_number_of_charts = len(charts_config_2) | ||
|
||
ImportAssetsCommand._import(session, base_configs) | ||
ImportAssetsCommand._import(session, new_configs) | ||
dashboard_ids = session.scalars( | ||
select(dashboard_slices.c.dashboard_id).distinct() | ||
).all() | ||
chart_ids = session.scalars(select(dashboard_slices.c.slice_id)).all() | ||
|
||
assert len(chart_ids) == expected_number_of_charts | ||
assert len(dashboard_ids) == expected_number_of_dashboards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. |
Oops, something went wrong.