feat: dataset api endpoint for charts and dashboards count (#10235)

* create GET endpoint for charts and dashboards count associated to a dataset

* add test for chart and dashboard count dataset
This commit is contained in:
Lily Kuang
2020-07-06 16:25:57 -07:00
committed by GitHub
parent 84f8a51458
commit b9e0678752
4 changed files with 136 additions and 0 deletions

View File

@@ -750,3 +750,17 @@ class TestDatasetApi(SupersetTestCase):
self.login(username="gamma")
rv = self.client.get(uri)
self.assertEqual(rv.status_code, 401)
def test_get_dataset_related_objects(self):
"""
Dataset API: Test get chart and dashboard count related to a dataset
:return:
"""
self.login(username="admin")
table = self.get_birth_names_dataset()
uri = f"api/v1/dataset/{table.id}/related_objects"
rv = self.get_assert_metric(uri, "related_objects")
self.assertEqual(rv.status_code, 200)
response = json.loads(rv.data.decode("utf-8"))
self.assertEqual(response["charts"]["count"], 18)
self.assertEqual(response["dashboards"]["count"], 2)