This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 3fe53f735e fix: Unable to export multiple Dashboards with the same
name (#20383)
3fe53f735e is described below
commit 3fe53f735e645a96ca5158054b5c9cb26e3e83e7
Author: Diego Medina <[email protected]>
AuthorDate: Wed Jun 15 03:27:24 2022 -0300
fix: Unable to export multiple Dashboards with the same name (#20383)
---
superset/dashboards/commands/export.py | 2 +-
tests/integration_tests/dashboards/commands_tests.py | 14 +++++++++-----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/superset/dashboards/commands/export.py
b/superset/dashboards/commands/export.py
index c7aa8b6e5c..2d131d8f84 100644
--- a/superset/dashboards/commands/export.py
+++ b/superset/dashboards/commands/export.py
@@ -112,7 +112,7 @@ class ExportDashboardsCommand(ExportModelsCommand):
model: Dashboard, export_related: bool = True
) -> Iterator[Tuple[str, str]]:
dashboard_slug = secure_filename(model.dashboard_title)
- file_name = f"dashboards/{dashboard_slug}.yaml"
+ file_name = f"dashboards/{dashboard_slug}_{model.id}.yaml"
payload = model.export_to_dict(
recursive=False,
diff --git a/tests/integration_tests/dashboards/commands_tests.py
b/tests/integration_tests/dashboards/commands_tests.py
index e3e6971155..d382a5f50d 100644
--- a/tests/integration_tests/dashboards/commands_tests.py
+++ b/tests/integration_tests/dashboards/commands_tests.py
@@ -68,7 +68,7 @@ class TestExportDashboardsCommand(SupersetTestCase):
expected_paths = {
"metadata.yaml",
- "dashboards/World_Banks_Data.yaml",
+ f"dashboards/World_Banks_Data_{example_dashboard.id}.yaml",
"datasets/examples/wb_health_population.yaml",
"databases/examples.yaml",
}
@@ -77,7 +77,9 @@ class TestExportDashboardsCommand(SupersetTestCase):
expected_paths.add(f"charts/{chart_slug}_{chart.id}.yaml")
assert expected_paths == set(contents.keys())
- metadata = yaml.safe_load(contents["dashboards/World_Banks_Data.yaml"])
+ metadata = yaml.safe_load(
+
contents[f"dashboards/World_Banks_Data_{example_dashboard.id}.yaml"]
+ )
# remove chart UUIDs from metadata so we can compare
for chart_info in metadata["position"].values():
@@ -269,7 +271,9 @@ class TestExportDashboardsCommand(SupersetTestCase):
command = ExportDashboardsCommand([example_dashboard.id])
contents = dict(command.run())
- metadata = yaml.safe_load(contents["dashboards/World_Banks_Data.yaml"])
+ metadata = yaml.safe_load(
+
contents[f"dashboards/World_Banks_Data_{example_dashboard.id}.yaml"]
+ )
assert list(metadata.keys()) == [
"dashboard_title",
"description",
@@ -284,7 +288,7 @@ class TestExportDashboardsCommand(SupersetTestCase):
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
@patch("superset.dashboards.commands.export.suffix")
def test_append_charts(self, mock_suffix):
- """Test that oprhaned charts are added to the dashbaord position"""
+ """Test that orphaned charts are added to the dashboard position"""
# return deterministic IDs
mock_suffix.side_effect = (str(i) for i in itertools.count(1))
@@ -435,7 +439,7 @@ class TestExportDashboardsCommand(SupersetTestCase):
expected_paths = {
"metadata.yaml",
- "dashboards/World_Banks_Data.yaml",
+ f"dashboards/World_Banks_Data_{example_dashboard.id}.yaml",
}
assert expected_paths == set(contents.keys())