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:
Zef Lin
2023-07-21 16:31:41 -07:00
committed by Michael S. Molina
parent a066ebbb5e
commit e3d8ecb478
2 changed files with 15 additions and 1 deletions

View File

@@ -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",