mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix: set importer as owner (#16656)
* fix: set importer as owner * Fix tests
This commit is contained in:
@@ -1715,6 +1715,9 @@ class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
|
||||
chart = db.session.query(Slice).filter_by(uuid=chart_config["uuid"]).one()
|
||||
assert chart.table == dataset
|
||||
|
||||
chart.owners = []
|
||||
dataset.owners = []
|
||||
database.owners = []
|
||||
db.session.delete(chart)
|
||||
db.session.delete(dataset)
|
||||
db.session.delete(database)
|
||||
@@ -1784,6 +1787,9 @@ class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
|
||||
dataset = database.tables[0]
|
||||
chart = db.session.query(Slice).filter_by(uuid=chart_config["uuid"]).one()
|
||||
|
||||
chart.owners = []
|
||||
dataset.owners = []
|
||||
database.owners = []
|
||||
db.session.delete(chart)
|
||||
db.session.delete(dataset)
|
||||
db.session.delete(database)
|
||||
|
||||
@@ -134,8 +134,10 @@ class TestExportChartsCommand(SupersetTestCase):
|
||||
|
||||
|
||||
class TestImportChartsCommand(SupersetTestCase):
|
||||
def test_import_v1_chart(self):
|
||||
@patch("superset.charts.commands.importers.v1.utils.g")
|
||||
def test_import_v1_chart(self, mock_g):
|
||||
"""Test that we can import a chart"""
|
||||
mock_g.user = security_manager.find_user("admin")
|
||||
contents = {
|
||||
"metadata.yaml": yaml.safe_dump(chart_metadata_config),
|
||||
"databases/imported_database.yaml": yaml.safe_dump(database_config),
|
||||
@@ -224,6 +226,11 @@ class TestImportChartsCommand(SupersetTestCase):
|
||||
assert database.database_name == "imported_database"
|
||||
assert chart.table.database == database
|
||||
|
||||
assert chart.owners == [mock_g.user]
|
||||
|
||||
chart.owners = []
|
||||
dataset.owners = []
|
||||
database.owners = []
|
||||
db.session.delete(chart)
|
||||
db.session.delete(dataset)
|
||||
db.session.delete(database)
|
||||
@@ -332,7 +339,7 @@ class TestChartsUpdateCommand(SupersetTestCase):
|
||||
@patch("superset.security.manager.g")
|
||||
@pytest.mark.usefixtures("load_energy_table_with_slice")
|
||||
def test_query_context_update_command(self, mock_sm_g, mock_g):
|
||||
""" "
|
||||
"""
|
||||
Test that a user can generate the chart query context
|
||||
payloadwithout affecting owners
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user