fix(import): only import FORMULA annotations (#26652)

This commit is contained in:
Maxime Beauchemin
2024-01-19 15:13:18 -08:00
committed by GitHub
parent 1283803844
commit e86d4d3c92
6 changed files with 83 additions and 5 deletions

View File

@@ -190,6 +190,7 @@ class TestImportChartsCommand(SupersetTestCase):
)
dataset = chart.datasource
assert json.loads(chart.params) == {
"annotation_layers": [],
"color_picker": {"a": 1, "b": 135, "g": 122, "r": 0},
"datasource": dataset.uid,
"js_columns": ["color"],

View File

@@ -160,7 +160,8 @@ def test_import_dashboards_versioned_export(import_dashboards_command, app_conte
runner = app.test_cli_runner()
response = runner.invoke(
superset.cli.importexport.import_dashboards, ("-p", "dashboards.json")
superset.cli.importexport.import_dashboards,
("-p", "dashboards.json", "-u", "admin"),
)
assert response.exit_code == 0
@@ -174,7 +175,8 @@ def test_import_dashboards_versioned_export(import_dashboards_command, app_conte
runner = app.test_cli_runner()
response = runner.invoke(
superset.cli.importexport.import_dashboards, ("-p", "dashboards.zip")
superset.cli.importexport.import_dashboards,
("-p", "dashboards.zip", "-u", "admin"),
)
assert response.exit_code == 0
@@ -205,7 +207,8 @@ def test_failing_import_dashboards_versioned_export(
runner = app.test_cli_runner()
response = runner.invoke(
superset.cli.importexport.import_dashboards, ("-p", "dashboards.json")
superset.cli.importexport.import_dashboards,
("-p", "dashboards.json", "-u", "admin"),
)
assert_cli_fails_properly(response, caplog)
@@ -217,7 +220,8 @@ def test_failing_import_dashboards_versioned_export(
runner = app.test_cli_runner()
response = runner.invoke(
superset.cli.importexport.import_dashboards, ("-p", "dashboards.zip")
superset.cli.importexport.import_dashboards,
("-p", "dashboards.zip", "-u", "admin"),
)
assert_cli_fails_properly(response, caplog)

View File

@@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from copy import deepcopy
from typing import Any
# example V0 import/export format
@@ -575,6 +576,40 @@ chart_config: dict[str, Any] = {
"version": "1.0.0",
"dataset_uuid": "10808100-158b-42c4-842e-f32b99d88dfb",
}
chart_config_with_mixed_annotations: dict[str, Any] = deepcopy(chart_config)
chart_config_with_mixed_annotations["params"]["annotation_layers"] = [
{
"name": "Formula test layer",
"annotationType": "FORMULA",
"color": None,
"descriptionColumns": [],
"hideLine": False,
"opacity": "",
"overrides": {"time_range": None},
"show": True,
"showLabel": False,
"showMarkers": False,
"style": "solid",
"value": "100000",
"width": 1,
},
{
"name": "Native layer to be removed on import",
"annotationType": "EVENT",
"sourceType": "NATIVE",
"color": None,
"opacity": "",
"style": "solid",
"width": 1,
"showMarkers": False,
"hideLine": False,
"value": 2,
"overrides": {"time_range": None},
"show": True,
"showLabel": False,
"descriptionColumns": [],
},
]
dashboard_config: dict[str, Any] = {
"dashboard_title": "Test dash",