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

@@ -1543,9 +1543,22 @@ class TestDatasetApi(SupersetTestCase):
assert rv.status_code == 422
assert response == {
"message": {
"datasets/imported_dataset.yaml": "Dataset already exists and `overwrite=true` was not passed"
}
"errors": [
{
"message": "Error importing dataset",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"datasets/imported_dataset.yaml": "Dataset 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
@@ -1599,7 +1612,25 @@ class TestDatasetApi(SupersetTestCase):
assert rv.status_code == 422
assert response == {
"message": {"metadata.yaml": {"type": ["Must be equal to SqlaTable."]}}
"errors": [
{
"message": "Error importing dataset",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"metadata.yaml": {"type": ["Must be equal to SqlaTable."]},
"issue_codes": [
{
"code": 1010,
"message": (
"Issue 1010 - Superset encountered "
"an error while running a command."
),
}
],
},
}
]
}
def test_import_dataset_invalid_v0_validation(self):
@@ -1628,4 +1659,20 @@ class TestDatasetApi(SupersetTestCase):
response = json.loads(rv.data.decode("utf-8"))
assert rv.status_code == 422
assert response == {"message": "Could not process entity"}
assert response == {
"errors": [
{
"message": "Could not find a valid command to import file",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"issue_codes": [
{
"code": 1010,
"message": "Issue 1010 - Superset encountered an error while running a command.",
}
]
},
}
]
}