villebro commented on code in PR #21911:
URL: https://github.com/apache/superset/pull/21911#discussion_r1002383735


##########
tests/integration_tests/dashboards/api_tests.py:
##########
@@ -803,6 +803,47 @@ def test_delete_bulk_dashboards(self):
             model = db.session.query(Dashboard).get(dashboard_id)
             self.assertEqual(model, None)
 
+    def test_delete_bulk_embedded_dashboards(self):
+        """
+        Dashboard API: Test delete bulk embedded
+        """
+        admin_id = self.get_user("admin").id
+        dashboard_count = 4
+        dashboard_ids = list()
+        for dashboard_name_index in range(dashboard_count):
+            dashboard_ids.append(
+                self.insert_dashboard(
+                    f"title{dashboard_name_index}",
+                    f"slug{dashboard_name_index}",
+                    [admin_id],
+                ).id
+            )
+        self.login(username="admin")
+        for dashboard_name_index in range(dashboard_count):
+            # post succeeds and returns value
+            allowed_domains = ["test.example", "embedded.example"]
+            resp = self.post_assert_metric(
+                f"api/v1/dashboard/slug{dashboard_name_index}/embedded",
+                {"allowed_domains": allowed_domains},
+                "set_embedded",
+            )
+            self.assertEqual(resp.status_code, 200)
+            result = json.loads(resp.data.decode("utf-8"))["result"]
+            self.assertIsNotNone(result["uuid"])
+            self.assertNotEqual(result["uuid"], "")
+            self.assertEqual(result["allowed_domains"], allowed_domains)
+        self.login(username="admin")

Review Comment:
   nit: to make this slightly DRYer, let's just specify the "admin" username 
once. Also, there's a redundant second login that doesn't appear to be needed.
   ```suggestion
           user = self.get_user("admin")
           dashboard_count = 4
           dashboard_ids = []
           for dashboard_name_index in range(dashboard_count):
               dashboard_ids.append(
                   self.insert_dashboard(
                       f"title{dashboard_name_index}",
                       f"slug{dashboard_name_index}",
                       [user.id],
                   ).id
               )
           self.login(username=user.username)
           for dashboard_name_index in range(dashboard_count):
               # post succeeds and returns value
               allowed_domains = ["test.example", "embedded.example"]
               resp = self.post_assert_metric(
                   f"api/v1/dashboard/slug{dashboard_name_index}/embedded",
                   {"allowed_domains": allowed_domains},
                   "set_embedded",
               )
               self.assertEqual(resp.status_code, 200)
               result = json.loads(resp.data.decode("utf-8"))["result"]
               self.assertIsNotNone(result["uuid"])
               self.assertNotEqual(result["uuid"], "")
               self.assertEqual(result["allowed_domains"], allowed_domains)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to