mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
chore(view_api): return application/json as content-type for api/v1/form_data endpoint (#24758)
(cherry picked from commit 0631a8086c)
This commit is contained in:
committed by
Michael S. Molina
parent
a066ebbb5e
commit
e3d8ecb478
@@ -86,7 +86,7 @@ class Api(BaseSupersetView):
|
|||||||
|
|
||||||
update_time_range(form_data)
|
update_time_range(form_data)
|
||||||
|
|
||||||
return json.dumps(form_data)
|
return self.json_response(form_data)
|
||||||
|
|
||||||
@api
|
@api
|
||||||
@handle_api_exception
|
@handle_api_exception
|
||||||
|
|||||||
@@ -1424,6 +1424,20 @@ class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
|
|||||||
self.assertEqual(rv.status_code, 200)
|
self.assertEqual(rv.status_code, 200)
|
||||||
self.assertEqual(len(data["result"]), 3)
|
self.assertEqual(len(data["result"]), 3)
|
||||||
|
|
||||||
|
def test_query_form_data(self):
|
||||||
|
"""
|
||||||
|
Chart API: Test query form data
|
||||||
|
"""
|
||||||
|
self.login(username="admin")
|
||||||
|
slice = db.session.query(Slice).first()
|
||||||
|
uri = f"api/v1/form_data/?slice_id={slice.id if slice else None}"
|
||||||
|
rv = self.client.get(uri)
|
||||||
|
data = json.loads(rv.data.decode("utf-8"))
|
||||||
|
self.assertEqual(rv.status_code, 200)
|
||||||
|
self.assertEqual(rv.content_type, "application/json")
|
||||||
|
if slice:
|
||||||
|
self.assertEqual(data["slice_id"], slice.id)
|
||||||
|
|
||||||
@pytest.mark.usefixtures(
|
@pytest.mark.usefixtures(
|
||||||
"load_unicode_dashboard_with_slice",
|
"load_unicode_dashboard_with_slice",
|
||||||
"load_energy_table_with_slice",
|
"load_energy_table_with_slice",
|
||||||
|
|||||||
Reference in New Issue
Block a user