mirror of
https://github.com/apache/superset.git
synced 2026-04-27 03:55:47 +00:00
fix: set importer as owner (#16656)
* fix: set importer as owner * Fix tests
This commit is contained in:
@@ -292,8 +292,11 @@ class TestImportDatasetsCommand(SupersetTestCase):
|
||||
db.session.delete(dataset)
|
||||
db.session.commit()
|
||||
|
||||
def test_import_v1_dataset(self):
|
||||
@patch("superset.datasets.commands.importers.v1.utils.g")
|
||||
@pytest.mark.usefixtures("load_energy_table_with_slice")
|
||||
def test_import_v1_dataset(self, mock_g):
|
||||
"""Test that we can import a dataset"""
|
||||
mock_g.user = security_manager.find_user("admin")
|
||||
contents = {
|
||||
"metadata.yaml": yaml.safe_dump(dataset_metadata_config),
|
||||
"databases/imported_database.yaml": yaml.safe_dump(database_config),
|
||||
@@ -319,6 +322,9 @@ class TestImportDatasetsCommand(SupersetTestCase):
|
||||
assert dataset.fetch_values_predicate is None
|
||||
assert dataset.extra == "dttm > sysdate() -10 "
|
||||
|
||||
# user should be included as one of the owners
|
||||
assert dataset.owners == [mock_g.user]
|
||||
|
||||
# database is also imported
|
||||
assert str(dataset.database.uuid) == "b8a1ccd3-779d-4ab7-8ad8-9ab119d7fe89"
|
||||
|
||||
@@ -346,6 +352,8 @@ class TestImportDatasetsCommand(SupersetTestCase):
|
||||
assert column.description is None
|
||||
assert column.python_date_format is None
|
||||
|
||||
dataset.owners = []
|
||||
dataset.database.owners = []
|
||||
db.session.delete(dataset)
|
||||
db.session.delete(dataset.database)
|
||||
db.session.commit()
|
||||
@@ -467,6 +475,8 @@ class TestImportDatasetsCommand(SupersetTestCase):
|
||||
)
|
||||
assert len(database.tables) == 1
|
||||
|
||||
database.tables[0].owners = []
|
||||
database.owners = []
|
||||
db.session.delete(database.tables[0])
|
||||
db.session.delete(database)
|
||||
db.session.commit()
|
||||
|
||||
Reference in New Issue
Block a user