fix: set importer as owner (#16656)

* fix: set importer as owner

* Fix tests
This commit is contained in:
Beto Dealmeida
2021-09-15 12:27:02 -07:00
committed by GitHub
parent 86290cc0e5
commit 092ef5bdfc
9 changed files with 55 additions and 5 deletions

View File

@@ -463,8 +463,10 @@ class TestImportDashboardsCommand(SupersetTestCase):
db.session.delete(dataset)
db.session.commit()
def test_import_v1_dashboard(self):
@patch("superset.dashboards.commands.importers.v1.utils.g")
def test_import_v1_dashboard(self, mock_g):
"""Test that we can import a dashboard"""
mock_g.user = security_manager.find_user("admin")
contents = {
"metadata.yaml": yaml.safe_dump(dashboard_metadata_config),
"databases/imported_database.yaml": yaml.safe_dump(database_config),
@@ -544,6 +546,12 @@ class TestImportDashboardsCommand(SupersetTestCase):
database = dataset.database
assert str(database.uuid) == database_config["uuid"]
assert dashboard.owners == [mock_g.user]
dashboard.owners = []
chart.owners = []
dataset.owners = []
database.owners = []
db.session.delete(dashboard)
db.session.delete(chart)
db.session.delete(dataset)