Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Mar 17, 2022
1 parent aa9df9b commit c532d79
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
7 changes: 4 additions & 3 deletions superset/commands/importers/v1/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ def _import(session: Session, configs: Dict[str, Any]) -> None:
# import charts
chart_ids: Dict[str, int] = {}
for file_name, config in configs.items():
config.update(dataset_info[config["dataset_uuid"]])
chart = import_chart(session, config, overwrite=True)
chart_ids[str(chart.uuid)] = chart.id
if file_name.startswith("charts/"):
config.update(dataset_info[config["dataset_uuid"]])
chart = import_chart(session, config, overwrite=True)
chart_ids[str(chart.uuid)] = chart.id

# store the existing relationship between dashboards and charts
existing_relationships = session.execute(
Expand Down
19 changes: 18 additions & 1 deletion tests/integration_tests/commands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_is_valid_config(self):

class TestImportAssetsCommand(SupersetTestCase):
@patch("superset.dashboards.commands.importers.v1.utils.g")
def test_import_v1_dashboard(self, mock_g):
def test_import_assets(self, mock_g):
"""Test that we can import multiple assets"""
mock_g.user = security_manager.find_user("admin")
contents = {
Expand Down Expand Up @@ -183,3 +183,20 @@ def test_import_v1_dashboard_overwrite(self, mock_g):
command.run()
chart = db.session.query(Slice).filter_by(uuid=chart_config["uuid"]).one()
assert chart.cache_timeout == 3600

dashboard = (
db.session.query(Dashboard).filter_by(uuid=dashboard_config["uuid"]).one()
)
chart = dashboard.slices[0]
dataset = chart.table
database = dataset.database
dashboard.owners = []

chart.owners = []
dataset.owners = []
database.owners = []
db.session.delete(dashboard)
db.session.delete(chart)
db.session.delete(dataset)
db.session.delete(database)
db.session.commit()

0 comments on commit c532d79

Please sign in to comment.