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

@@ -1633,9 +1633,22 @@ class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
assert rv.status_code == 422
assert response == {
"message": {
"charts/imported_chart.yaml": "Chart already exists and `overwrite=true` was not passed"
}
"errors": [
{
"message": "Error importing chart",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"charts/imported_chart.yaml": "Chart 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
@@ -1691,7 +1704,25 @@ class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
assert rv.status_code == 422
assert response == {
"message": {"metadata.yaml": {"type": ["Must be equal to Slice."]}}
"errors": [
{
"message": "Error importing chart",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"metadata.yaml": {"type": ["Must be equal to Slice."]},
"issue_codes": [
{
"code": 1010,
"message": (
"Issue 1010 - Superset encountered an "
"error while running a command."
),
}
],
},
}
]
}
@pytest.mark.usefixtures(