Skip to content

Commit

Permalink
fix: deactivate embedding on a dashboard (#19626)
Browse files Browse the repository at this point in the history
* fix tests

* commit it properly

* unnecessary commit, correct type in docstring

* unused import
  • Loading branch information
suddjian authored Apr 15, 2022
1 parent 06ec88e commit ae70212
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion superset/dao/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def update(
def delete(cls, model: Model, commit: bool = True) -> Model:
"""
Generic delete a model
:raises: DAOCreateFailedError
:raises: DAODeleteFailedError
"""
try:
db.session.delete(model)
Expand Down
3 changes: 2 additions & 1 deletion superset/dashboards/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,5 +1191,6 @@ def delete_embedded(self, dashboard: Dashboard) -> Response:
500:
$ref: '#/components/responses/500'
"""
dashboard.embedded = []
for embedded in dashboard.embedded:
DashboardDAO.delete(embedded)
return self.response(200, message="OK")
10 changes: 9 additions & 1 deletion tests/integration_tests/dashboards/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,8 @@ def test_embedded_dashboards(self):
self.assertNotEqual(result["uuid"], "")
self.assertEqual(result["allowed_domains"], allowed_domains)

db.session.expire_all()

# get returns value
resp = self.get_assert_metric(uri, "get_embedded")
self.assertEqual(resp.status_code, 200)
Expand All @@ -1810,9 +1812,13 @@ def test_embedded_dashboards(self):
# put succeeds and returns value
resp = self.post_assert_metric(uri, {"allowed_domains": []}, "set_embedded")
self.assertEqual(resp.status_code, 200)
result = json.loads(resp.data.decode("utf-8"))["result"]
self.assertEqual(resp.status_code, 200)
self.assertIsNotNone(result["uuid"])
self.assertNotEqual(result["uuid"], "")
self.assertEqual(result["allowed_domains"], allowed_domains)
self.assertEqual(result["allowed_domains"], [])

db.session.expire_all()

# get returns changed value
resp = self.get_assert_metric(uri, "get_embedded")
Expand All @@ -1825,6 +1831,8 @@ def test_embedded_dashboards(self):
resp = self.delete_assert_metric(uri, "delete_embedded")
self.assertEqual(resp.status_code, 200)

db.session.expire_all()

# get returns 404
resp = self.get_assert_metric(uri, "get_embedded")
self.assertEqual(resp.status_code, 404)

0 comments on commit ae70212

Please sign in to comment.