Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: chart id mapping in dashboard api #22179

Merged
merged 2 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion superset/charts/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#
# 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."
Expand Down Expand Up @@ -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)
Expand Down
20 changes: 16 additions & 4 deletions tests/integration_tests/dashboards/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,22 @@ def test_get_dashboard_charts(self):
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):
Expand Down