betodealmeida commented on a change in pull request #13997:
URL: https://github.com/apache/superset/pull/13997#discussion_r609860428
##########
File path: tests/databases/api_tests.py
##########
@@ -895,138 +898,55 @@ def test_test_connection_unsafe_uri(self):
app.config["PREVENT_UNSAFE_DB_CONNECTIONS"] = False
-
@mock.patch("superset.databases.commands.test_connection.is_hostname_valid",)
- def test_test_connection_failed_invalid_hostname(self,
mock_is_hostname_valid):
- """
- Database API: Test test connection failed due to invalid hostname
- """
- mock_is_hostname_valid.return_value = False
-
- self.login("admin")
- data = {
- "sqlalchemy_uri":
"postgres://username:password@invalidhostname:12345/db",
- "database_name": "examples",
- "impersonate_user": False,
- "server_cert": None,
- }
- url = "api/v1/database/test_connection"
- rv = self.post_assert_metric(url, data, "test_connection")
-
- assert rv.status_code == 400
- assert rv.headers["Content-Type"] == "application/json; charset=utf-8"
- response = json.loads(rv.data.decode("utf-8"))
- expected_response = {
- "errors": [
- {
- "message": 'Unable to resolve hostname "invalidhostname".',
- "error_type": "TEST_CONNECTION_INVALID_HOSTNAME_ERROR",
- "level": "error",
- "extra": {
- "hostname": "invalidhostname",
- "issue_codes": [
- {
- "code": 1007,
- "message": "Issue 1007 - The hostname provided
can't be resolved.",
- }
- ],
- },
- }
- ]
- }
- assert response == expected_response
-
-
@mock.patch("superset.databases.commands.test_connection.is_hostname_valid")
- @mock.patch("superset.databases.commands.test_connection.is_port_open")
- @mock.patch("superset.databases.commands.test_connection.is_host_up")
- def test_test_connection_failed_closed_port(
Review comment:
We don't, we don't test this explicitly anymore, but instead rely on the
driver to give this information. Because of this we only need one API test now.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]