fix: show error on invalid import (#14851)

* fix: show error on invalid import

* Add unit test

* Remove unused imports

* Fix tests
This commit is contained in:
Beto Dealmeida
2021-05-27 14:46:41 -07:00
committed by GitHub
parent 8febd81baf
commit 2313e3ef4f
10 changed files with 262 additions and 79 deletions

View File

@@ -1208,9 +1208,25 @@ class TestDatabaseApi(SupersetTestCase):
assert rv.status_code == 422
assert response == {
"message": {
"databases/imported_database.yaml": "Database already exists and `overwrite=true` was not passed"
}
"errors": [
{
"message": "Error importing database",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"databases/imported_database.yaml": "Database already exists and `overwrite=true` was not passed",
"issue_codes": [
{
"code": 1010,
"message": (
"Issue 1010 - Superset encountered an "
"error while running a command."
),
}
],
},
}
]
}
# import with overwrite flag
@@ -1263,7 +1279,25 @@ class TestDatabaseApi(SupersetTestCase):
assert rv.status_code == 422
assert response == {
"message": {"metadata.yaml": {"type": ["Must be equal to Database."]}}
"errors": [
{
"message": "Error importing database",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"metadata.yaml": {"type": ["Must be equal to Database."]},
"issue_codes": [
{
"code": 1010,
"message": (
"Issue 1010 - Superset encountered an "
"error while running a command."
),
}
],
},
}
]
}
def test_import_database_masked_password(self):
@@ -1300,11 +1334,27 @@ class TestDatabaseApi(SupersetTestCase):
assert rv.status_code == 422
assert response == {
"message": {
"databases/imported_database.yaml": {
"_schema": ["Must provide a password for the database"]
"errors": [
{
"message": "Error importing database",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"databases/imported_database.yaml": {
"_schema": ["Must provide a password for the database"]
},
"issue_codes": [
{
"code": 1010,
"message": (
"Issue 1010 - Superset encountered an "
"error while running a command."
),
}
],
},
}
}
]
}
def test_import_database_masked_password_provided(self):