You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by dp...@apache.org on 2020/04/27 08:24:55 UTC
[incubator-superset] branch master updated: fix(database): test
connection error message for module not found (#9634)
This is an automated email from the ASF dual-hosted git repository.
dpgaspar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new f07ca7d fix(database): test connection error message for module not found (#9634)
f07ca7d is described below
commit f07ca7d8364122c1cd66845ccf66095d185bcdcc
Author: Daniel Vaz Gaspar <da...@gmail.com>
AuthorDate: Mon Apr 27 09:24:41 2020 +0100
fix(database): test connection error message for module not found (#9634)
---
superset/views/core.py | 2 +-
tests/core_tests.py | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/superset/views/core.py b/superset/views/core.py
index 30eb6fe..b113db8 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -1376,7 +1376,7 @@ class Superset(BaseSupersetView):
except CertificateException as ex:
logger.info(ex.message)
return json_error_response(ex.message)
- except NoSuchModuleError as ex:
+ except (NoSuchModuleError, ModuleNotFoundError) as ex:
logger.info("Invalid driver %s", ex)
driver_name = make_url(uri).drivername
return json_error_response(
diff --git a/tests/core_tests.py b/tests/core_tests.py
index b3d8cad..3bd9e0d 100644
--- a/tests/core_tests.py
+++ b/tests/core_tests.py
@@ -439,6 +439,25 @@ class CoreTests(SupersetTestCase):
expected_body,
)
+ data = json.dumps(
+ {
+ "uri": "mssql+pymssql://url",
+ "name": "examples",
+ "impersonate_user": False,
+ }
+ )
+ response = self.client.post(
+ "/superset/testconn", data=data, content_type="application/json"
+ )
+ assert response.status_code == 400
+ assert response.headers["Content-Type"] == "application/json"
+ response_body = json.loads(response.data.decode("utf-8"))
+ expected_body = {"error": "Could not load database driver: mssql+pymssql"}
+ assert response_body == expected_body, "%s != %s" % (
+ response_body,
+ expected_body,
+ )
+
def test_testconn_unsafe_uri(self, username="admin"):
self.login(username=username)
app.config["PREVENT_UNSAFE_DB_CONNECTIONS"] = True