From f8bb103d4fc4d7c962437c89809132d44f4d30f1 Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Tue, 13 Apr 2021 14:43:13 -0700 Subject: [PATCH] Address comments --- superset/db_engine_specs/mssql.py | 10 +++++----- superset/db_engine_specs/postgres.py | 6 +++--- tests/db_engine_specs/mssql_tests.py | 10 +++++----- tests/db_engine_specs/postgres_tests.py | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/superset/db_engine_specs/mssql.py b/superset/db_engine_specs/mssql.py index 55e6387b58ba0..51873ced349a6 100644 --- a/superset/db_engine_specs/mssql.py +++ b/superset/db_engine_specs/mssql.py @@ -30,7 +30,7 @@ # Regular expressions to catch custom errors TEST_CONNECTION_ACCESS_DENIED_REGEX = re.compile("Adaptive Server connection failed") -TEXT_CONNECTION_INVALID_HOSTNAME_REGEX = re.compile( +TEST_CONNECTION_INVALID_HOSTNAME_REGEX = re.compile( r"Adaptive Server is unavailable or does not exist \((?P.*?)\)" "(?!.*Net-Lib error).*$" ) @@ -69,18 +69,18 @@ class MssqlEngineSpec(BaseEngineSpec): __('Either the username "%(username)s" or the password is incorrect.'), SupersetErrorType.TEST_CONNECTION_ACCESS_DENIED_ERROR, ), - TEXT_CONNECTION_INVALID_HOSTNAME_REGEX: ( + TEST_CONNECTION_INVALID_HOSTNAME_REGEX: ( __('The hostname "%(hostname)s" cannot be resolved.'), SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, ), TEST_CONNECTION_PORT_CLOSED_REGEX: ( - __("Port %(port)s on hostname %(hostname)s refused the connection."), + __('Port %(port)s on hostname "%(hostname)s" refused the connection.'), SupersetErrorType.TEST_CONNECTION_PORT_CLOSED_ERROR, ), TEST_CONNECTION_HOST_DOWN_REGEX: ( __( - "The host %(hostname)s might be down, and can't be " - "reached on port %(port)s" + 'The host "%(hostname)s" might be down, and can\'t be ' + "reached on port %(port)s." ), SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, ), diff --git a/superset/db_engine_specs/postgres.py b/superset/db_engine_specs/postgres.py index 04f0f78c28542..59effff0cd7b8 100644 --- a/superset/db_engine_specs/postgres.py +++ b/superset/db_engine_specs/postgres.py @@ -110,13 +110,13 @@ class PostgresBaseEngineSpec(BaseEngineSpec): SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, ), TEST_CONNECTION_PORT_CLOSED_REGEX: ( - __("Port %(port)s on hostname %(hostname)s refused the connection."), + __('Port %(port)s on hostname "%(hostname)s" refused the connection.'), SupersetErrorType.TEST_CONNECTION_PORT_CLOSED_ERROR, ), TEST_CONNECTION_HOST_DOWN_REGEX: ( __( - "The host %(hostname)s might be down, and can't be " - "reached on port %(port)s" + 'The host "%(hostname)s" might be down, and can\'t be ' + "reached on port %(port)s." ), SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, ), diff --git a/tests/db_engine_specs/mssql_tests.py b/tests/db_engine_specs/mssql_tests.py index cce87c93c96d0..cfc75cf09e8e5 100644 --- a/tests/db_engine_specs/mssql_tests.py +++ b/tests/db_engine_specs/mssql_tests.py @@ -196,7 +196,7 @@ def test_extract_errors(self): assert result == [ SupersetError( error_type=SupersetErrorType.TEST_CONNECTION_PORT_CLOSED_ERROR, - message="Port 12345 on hostname localhost refused the connection.", + message='Port 12345 on hostname "localhost" refused the connection.', level=ErrorLevel.ERROR, extra={ "engine_name": "Microsoft SQL", @@ -224,8 +224,8 @@ def test_extract_errors(self): SupersetError( error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, message=( - "The host example.com might be down, " - "and can't be reached on port 12345" + 'The host "example.com" might be down, ' + "and can't be reached on port 12345." ), level=ErrorLevel.ERROR, extra={ @@ -257,8 +257,8 @@ def test_extract_errors(self): SupersetError( error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, message=( - "The host 93.184.216.34 might be down, " - "and can't be reached on port 12345" + 'The host "93.184.216.34" might be down, ' + "and can't be reached on port 12345." ), level=ErrorLevel.ERROR, extra={ diff --git a/tests/db_engine_specs/postgres_tests.py b/tests/db_engine_specs/postgres_tests.py index a8e99415144b5..867faa1265fb0 100644 --- a/tests/db_engine_specs/postgres_tests.py +++ b/tests/db_engine_specs/postgres_tests.py @@ -271,7 +271,7 @@ def test_extract_errors(self): assert result == [ SupersetError( error_type=SupersetErrorType.TEST_CONNECTION_PORT_CLOSED_ERROR, - message="Port 12345 on hostname localhost refused the connection.", + message='Port 12345 on hostname "localhost" refused the connection.', level=ErrorLevel.ERROR, extra={ "engine_name": "PostgreSQL", @@ -294,8 +294,8 @@ def test_extract_errors(self): SupersetError( error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, message=( - "The host example.com might be down, " - "and can't be reached on port 12345" + 'The host "example.com" might be down, ' + "and can't be reached on port 12345." ), level=ErrorLevel.ERROR, extra={ @@ -323,8 +323,8 @@ def test_extract_errors(self): SupersetError( error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, message=( - "The host 93.184.216.34 might be down, " - "and can't be reached on port 12345" + 'The host "93.184.216.34" might be down, ' + "and can't be reached on port 12345." ), level=ErrorLevel.ERROR, extra={