This is an automated email from the ASF dual-hosted git repository.
suddjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new ae70212df3 fix: deactivate embedding on a dashboard (#19626)
ae70212df3 is described below
commit ae70212df31e4e483a9c316898419a55389fe619
Author: David Aaron Suddjian <[email protected]>
AuthorDate: Fri Apr 15 16:15:27 2022 -0700
fix: deactivate embedding on a dashboard (#19626)
* fix tests
* commit it properly
* unnecessary commit, correct type in docstring
* unused import
---
superset/dao/base.py | 2 +-
superset/dashboards/api.py | 3 ++-
tests/integration_tests/dashboards/api_tests.py | 10 +++++++++-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/superset/dao/base.py b/superset/dao/base.py
index 607967e304..0090c4e535 100644
--- a/superset/dao/base.py
+++ b/superset/dao/base.py
@@ -175,7 +175,7 @@ class BaseDAO:
def delete(cls, model: Model, commit: bool = True) -> Model:
"""
Generic delete a model
- :raises: DAOCreateFailedError
+ :raises: DAODeleteFailedError
"""
try:
db.session.delete(model)
diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py
index fb9c36ca03..277e0d10c3 100644
--- a/superset/dashboards/api.py
+++ b/superset/dashboards/api.py
@@ -1191,5 +1191,6 @@ class DashboardRestApi(BaseSupersetModelRestApi):
500:
$ref: '#/components/responses/500'
"""
- dashboard.embedded = []
+ for embedded in dashboard.embedded:
+ DashboardDAO.delete(embedded)
return self.response(200, message="OK")
diff --git a/tests/integration_tests/dashboards/api_tests.py
b/tests/integration_tests/dashboards/api_tests.py
index afeab6e7db..a027dcffae 100644
--- a/tests/integration_tests/dashboards/api_tests.py
+++ b/tests/integration_tests/dashboards/api_tests.py
@@ -1796,6 +1796,8 @@ class TestDashboardApi(SupersetTestCase,
ApiOwnersTestCaseMixin, InsertChartMixi
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)
@@ -1810,9 +1812,13 @@ class TestDashboardApi(SupersetTestCase,
ApiOwnersTestCaseMixin, InsertChartMixi
# 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")
@@ -1825,6 +1831,8 @@ class TestDashboardApi(SupersetTestCase,
ApiOwnersTestCaseMixin, InsertChartMixi
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)