This is an automated email from the ASF dual-hosted git repository.

villebro 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 ac0ff78616 fix: chart id mapping in dashboard api (#22179)
ac0ff78616 is described below

commit ac0ff78616119bd5d8bebbb2781e0ef3486c4d19
Author: Ville Brofeldt <[email protected]>
AuthorDate: Mon Nov 21 18:30:08 2022 +0200

    fix: chart id mapping in dashboard api (#22179)
    
    Co-authored-by: Ville Brofeldt <[email protected]>
---
 superset/charts/schemas.py                      |  3 ++-
 tests/integration_tests/dashboards/api_tests.py | 20 ++++++++++++++++----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/superset/charts/schemas.py b/superset/charts/schemas.py
index 34dd44b38c..6033e09035 100644
--- a/superset/charts/schemas.py
+++ b/superset/charts/schemas.py
@@ -71,6 +71,7 @@ get_fav_star_ids_schema = {"type": "array", "items": {"type": 
"integer"}}
 #
 # Column schema descriptions
 #
+id_description = "The id of the chart."
 slice_name_description = "The name of the chart."
 description_description = "A description of the chart propose."
 viz_type_description = "The type of chart visualization used."
@@ -153,7 +154,7 @@ class ChartEntityResponseSchema(Schema):
     Schema for a chart object
     """
 
-    slice_id = fields.Integer()
+    id = fields.Integer(description=id_description)
     slice_name = fields.String(description=slice_name_description)
     cache_timeout = fields.Integer(description=cache_timeout_description)
     changed_on = fields.String(description=changed_on_description)
diff --git a/tests/integration_tests/dashboards/api_tests.py 
b/tests/integration_tests/dashboards/api_tests.py
index 35f59f3639..1ca80aae38 100644
--- a/tests/integration_tests/dashboards/api_tests.py
+++ b/tests/integration_tests/dashboards/api_tests.py
@@ -275,10 +275,22 @@ class TestDashboardApi(SupersetTestCase, 
ApiOwnersTestCaseMixin, InsertChartMixi
         response = self.get_assert_metric(uri, "get_charts")
         self.assertEqual(response.status_code, 200)
         data = json.loads(response.data.decode("utf-8"))
-        self.assertEqual(len(data["result"]), 1)
-        self.assertEqual(
-            data["result"][0]["slice_name"], dashboard.slices[0].slice_name
-        )
+        assert len(data["result"]) == 1
+        result = data["result"][0]
+        assert set(result.keys()) == {
+            "cache_timeout",
+            "certification_details",
+            "certified_by",
+            "changed_on",
+            "description",
+            "description_markeddown",
+            "form_data",
+            "id",
+            "slice_name",
+            "slice_url",
+        }
+        assert result["id"] == dashboard.slices[0].id
+        assert result["slice_name"] == dashboard.slices[0].slice_name
 
     @pytest.mark.usefixtures("create_dashboards")
     def test_get_dashboard_charts_by_slug(self):

Reply via email to