chore(view_api): return application/json as content-type for api/v1/form_data endpoint (#24758)
This commit is contained in:
parent
e06004292a
commit
0631a8086c
|
|
@ -86,7 +86,7 @@ class Api(BaseSupersetView):
|
|||
|
||||
update_time_range(form_data)
|
||||
|
||||
return json.dumps(form_data)
|
||||
return self.json_response(form_data)
|
||||
|
||||
@api
|
||||
@handle_api_exception
|
||||
|
|
|
|||
|
|
@ -1424,6 +1424,20 @@ class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
|
|||
self.assertEqual(rv.status_code, 200)
|
||||
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(
|
||||
"load_unicode_dashboard_with_slice",
|
||||
"load_energy_table_with_slice",
|
||||
|
|
|
|||
Loading…
Reference in New Issue