mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
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:
@@ -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.",
|
||||
}
|
||||
]
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user