You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2021/11/19 17:59:28 UTC

[superset] branch master updated: chore(sql_lab): Added Unit Test for stop query exception (#17464)

This is an automated email from the ASF dual-hosted git repository.

hugh 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 69c3cc7  chore(sql_lab): Added Unit Test for stop query exception (#17464)
69c3cc7 is described below

commit 69c3cc712d8399a81b5b1b4783ea17a8c1f1cf70
Author: AAfghahi <48...@users.noreply.github.com>
AuthorDate: Fri Nov 19 12:58:12 2021 -0500

    chore(sql_lab): Added Unit Test for stop query exception (#17464)
    
    * added unit test
    
    * feedback implemented
---
 tests/integration_tests/core_tests.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/tests/integration_tests/core_tests.py b/tests/integration_tests/core_tests.py
index 3b9a397..dd84f97 100644
--- a/tests/integration_tests/core_tests.py
+++ b/tests/integration_tests/core_tests.py
@@ -1547,6 +1547,28 @@ class TestCore(SupersetTestCase):
         data = self.get_resp(url)
         self.assertIn("Error message", data)
 
+    @mock.patch("superset.sql_lab.cancel_query")
+    @mock.patch("superset.views.core.db.session")
+    def test_stop_query_not_implemented(
+        self, mock_superset_db_session, mock_sql_lab_cancel_query
+    ):
+        """
+        Handles stop query when the DB engine spec does not
+        have a cancel query method.
+        """
+        form_data = {"client_id": "foo"}
+        query_mock = mock.Mock()
+        query_mock.client_id = "foo"
+        query_mock.status = QueryStatus.RUNNING
+        self.login(username="admin")
+        mock_superset_db_session.query().filter_by().one().return_value = query_mock
+        mock_sql_lab_cancel_query.return_value = False
+        rv = self.client.post(
+            "/superset/stop_query/", data={"form_data": json.dumps(form_data)},
+        )
+
+        assert rv.status_code == 422
+
 
 if __name__ == "__main__":
     unittest.main()