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

@@ -108,3 +108,22 @@ def test_import_chart_without_permission(
str(excinfo.value)
== "Chart doesn't exist and user doesn't have permission to create charts"
)
def test_filter_chart_annotations(mocker: MockFixture, session: Session) -> None:
"""
Test importing a chart.
"""
from superset import security_manager
from superset.commands.chart.importers.v1.utils import filter_chart_annotations
from tests.integration_tests.fixtures.importexport import (
chart_config_with_mixed_annotations,
)
config = copy.deepcopy(chart_config_with_mixed_annotations)
filter_chart_annotations(config)
params = config["params"]
annotation_layers = params["annotation_layers"]
assert len(annotation_layers) == 1
assert all([al["annotationType"] == "FORMULA" for al in annotation_layers])