Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Glutexo committed Sep 2, 2024
1 parent 72b14b5 commit ea90079
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions insights/tests/client/connection/test_test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def insights_connection(get_proxies, init_session):

@parametrize_exceptions
@patch("insights.client.connection.InsightsConnection._test_urls")
def test_test_connection_request_failed_test_urls(test_urls, exception, insights_connection):
def test_test_connection_fail_test_urls(test_urls, exception, insights_connection):
"""The whole connection test is stopped when an API call fails."""
test_urls.side_effect = exception

Expand All @@ -58,7 +58,7 @@ def test_test_connection_request_failed_test_urls(test_urls, exception, insights

@parametrize_exceptions
@patch("insights.client.connection.InsightsConnection._test_urls")
def test_test_connection_request_failed_print(test_urls, exception, insights_connection, capsys):
def test_test_connection_fail_print(test_urls, exception, insights_connection, capsys):
"""A message pointing to the log file is printed."""
test_urls.side_effect = exception

Expand All @@ -70,7 +70,7 @@ def test_test_connection_request_failed_print(test_urls, exception, insights_con

@parametrize_exceptions
@patch("insights.client.connection.InsightsConnection._test_urls")
def test_test_connection_request_failed_error_log(test_urls, exception, insights_connection, caplog):
def test_test_connection_fail_error_log(test_urls, exception, insights_connection, caplog):
"""An error message is logged on the ERROR level."""
test_urls.side_effect = exception

Expand All @@ -84,14 +84,31 @@ def test_test_connection_request_failed_error_log(test_urls, exception, insights

@parametrize_exceptions
@patch("insights.client.connection.InsightsConnection._test_urls")
def test_test_connection_request_failed_return_code(test_urls, exception, insights_connection):
def test_test_connection_fail_return_code(test_urls, exception, insights_connection):
"""Status code 1 is returned from the function."""
test_urls.side_effect = exception

result = insights_connection.test_connection()
assert result == 1


@parametrize_exceptions
@patch("insights.client.connection.InsightsConnection.post")
def test_test_connection_non_legacy_fail_error_log(post, exception, insights_connection):
post.side_effect = exception
insights_connection.config.legacy_upload = False

with caplog.at_level(ERROR, logger="insights.client.connection"):
insights_connection.test_connection()

assert caplog.record_tuples == [
("insights.client.connection", ERROR, message)
for message in [
"Could not successfully connect to: %s" % (REQUEST_URL,),
("insights.client.connection", ERROR, "Connectivity test failed! Please check your network configuration")
]


@parametrize_methods
@patch("insights.client.connection.InsightsConnection._legacy_test_urls")
def test_test_urls_legacy_test_urls(legacy_test_urls, http_method, request_function, insights_connection):
Expand Down

0 comments on commit ea90079

Please sign in to comment.