Skip to content

Commit

Permalink
Fix lint and test
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Apr 7, 2021
1 parent 273667f commit a2d5833
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
1 change: 1 addition & 0 deletions superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ def common_bootstrap_payload() -> Dict[str, Any]:
}


# pylint: disable=invalid-name
def get_error_level_from_status_code(status: int) -> ErrorLevel:
if status < 400:
return ErrorLevel.INFO
Expand Down
53 changes: 50 additions & 3 deletions tests/databases/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,22 @@ def test_test_connection_failed_invalid_hostname(self, mock_is_hostname_valid):
assert rv.headers["Content-Type"] == "application/json; charset=utf-8"
response = json.loads(rv.data.decode("utf-8"))
expected_response = {
"message": 'Unable to resolve hostname "invalidhostname".',
"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

Expand Down Expand Up @@ -947,7 +962,23 @@ def test_test_connection_failed_closed_port(
assert rv.headers["Content-Type"] == "application/json; charset=utf-8"
response = json.loads(rv.data.decode("utf-8"))
expected_response = {
"message": "The host localhost is up, but the port 12345 is closed.",
"errors": [
{
"message": "The host localhost is up, but the port 12345 is closed.",
"error_type": "TEST_CONNECTION_PORT_CLOSED_ERROR",
"level": "error",
"extra": {
"hostname": "localhost",
"port": 12345,
"issue_codes": [
{
"code": 1008,
"message": "Issue 1008 - The port is closed.",
}
],
},
}
]
}
assert response == expected_response

Expand Down Expand Up @@ -978,7 +1009,23 @@ def test_test_connection_failed_host_down(
assert rv.headers["Content-Type"] == "application/json; charset=utf-8"
response = json.loads(rv.data.decode("utf-8"))
expected_response = {
"message": "The host localhost might be down, ond can't be reached on port 12345.",
"errors": [
{
"message": "The host localhost might be down, ond can't be reached on port 12345.",
"error_type": "TEST_CONNECTION_HOST_DOWN_ERROR",
"level": "error",
"extra": {
"hostname": "localhost",
"port": 12345,
"issue_codes": [
{
"code": 1009,
"message": "Issue 1009 - The host might be down, and can't be reached on the provided port.",
}
],
},
}
]
}
assert response == expected_response

Expand Down

0 comments on commit a2d5833

Please sign in to comment.