From 10cec5d47ff6699389ac11dc68662cd198fbd123 Mon Sep 17 00:00:00 2001 From: Sylvain Hellegouarch Date: Sat, 15 Jun 2024 22:34:56 +0200 Subject: [PATCH] delint Signed-off-by: Sylvain Hellegouarch --- chaosaws/cloudwatch/probes.py | 6 +++--- chaosaws/elbv2/actions.py | 10 +++++----- chaosaws/elbv2/probes.py | 10 +++++----- chaosaws/msk/actions.py | 9 ++++----- tests/msk/test_msk_actions.py | 32 ++++++++++---------------------- tests/msk/test_msk_probes.py | 14 ++++---------- 6 files changed, 31 insertions(+), 50 deletions(-) diff --git a/chaosaws/cloudwatch/probes.py b/chaosaws/cloudwatch/probes.py index d9a94d4..480f0fe 100644 --- a/chaosaws/cloudwatch/probes.py +++ b/chaosaws/cloudwatch/probes.py @@ -182,9 +182,9 @@ def get_metric_data( } if dimensions: - args["MetricDataQueries"][0]["MetricStat"]["Metric"][ - "Dimensions" - ] = dimensions + args["MetricDataQueries"][0]["MetricStat"]["Metric"]["Dimensions"] = ( + dimensions + ) elif dimension_name and dimension_value: args["MetricDataQueries"][0]["MetricStat"]["Metric"]["Dimensions"] = [ {"Name": dimension_name, "Value": dimension_value} diff --git a/chaosaws/elbv2/actions.py b/chaosaws/elbv2/actions.py index a0b0f09..a6c25ea 100644 --- a/chaosaws/elbv2/actions.py +++ b/chaosaws/elbv2/actions.py @@ -304,11 +304,11 @@ def get_targets_health_description(tg_arns: Dict, client: boto3.client) -> Dict: for tg in tg_arns: tg_health_descr[tg] = {} tg_health_descr[tg]["TargetGroupArn"] = tg_arns[tg] - tg_health_descr[tg][ - "TargetHealthDescriptions" - ] = client.describe_target_health(TargetGroupArn=tg_arns[tg])[ - "TargetHealthDescriptions" - ] + tg_health_descr[tg]["TargetHealthDescriptions"] = ( + client.describe_target_health( + TargetGroupArn=tg_arns[tg] + )["TargetHealthDescriptions"] + ) logger.debug( f"Health descriptions for target group(s) are: {str(tg_health_descr)}" ) diff --git a/chaosaws/elbv2/probes.py b/chaosaws/elbv2/probes.py index 4934734..d6823f2 100644 --- a/chaosaws/elbv2/probes.py +++ b/chaosaws/elbv2/probes.py @@ -139,11 +139,11 @@ def get_targets_health_description(tg_arns: Dict, client: boto3.client) -> Dict: for tg in tg_arns: tg_health_descr[tg] = {} tg_health_descr[tg]["TargetGroupArn"] = tg_arns[tg] - tg_health_descr[tg][ - "TargetHealthDescriptions" - ] = client.describe_target_health(TargetGroupArn=tg_arns[tg])[ - "TargetHealthDescriptions" - ] + tg_health_descr[tg]["TargetHealthDescriptions"] = ( + client.describe_target_health( + TargetGroupArn=tg_arns[tg] + )["TargetHealthDescriptions"] + ) logger.debug( f"Health descriptions for target group(s) are: {str(tg_health_descr)}" ) diff --git a/chaosaws/msk/actions.py b/chaosaws/msk/actions.py index a364781..b26c827 100644 --- a/chaosaws/msk/actions.py +++ b/chaosaws/msk/actions.py @@ -23,14 +23,13 @@ def reboot_msk_broker( client = aws_client("kafka", configuration, secrets) logger.debug( f"Rebooting MSK brokers: {broker_ids} in cluster {cluster_arn}" - ) + ) try: return client.reboot_broker( - ClusterArn=cluster_arn, - BrokerIds=broker_ids + ClusterArn=cluster_arn, BrokerIds=broker_ids ) except client.exceptions.NotFoundException: - raise FailedActivity("The specified cluster was not found" ) + raise FailedActivity("The specified cluster was not found") def delete_cluster( @@ -46,4 +45,4 @@ def delete_cluster( try: return client.delete_cluster(ClusterArn=cluster_arn) except client.exceptions.NotFoundException: - raise FailedActivity("The specified cluster was not found") \ No newline at end of file + raise FailedActivity("The specified cluster was not found") diff --git a/tests/msk/test_msk_actions.py b/tests/msk/test_msk_actions.py index ffdf1fa..fc3f976 100644 --- a/tests/msk/test_msk_actions.py +++ b/tests/msk/test_msk_actions.py @@ -16,16 +16,14 @@ def test_reboot_msk_broker_success(aws_client): cluster_arn = "arn_msk_cluster" broker_ids = ["1"] client.reboot_broker.return_value = { - "ResponseMetadata": { - "HTTPStatusCode": 200 - } + "ResponseMetadata": {"HTTPStatusCode": 200} } - response = reboot_msk_broker(cluster_arn=cluster_arn, - broker_ids=broker_ids) + response = reboot_msk_broker(cluster_arn=cluster_arn, broker_ids=broker_ids) - client.reboot_broker.assert_called_with(ClusterArn=cluster_arn, - BrokerIds=broker_ids) + client.reboot_broker.assert_called_with( + ClusterArn=cluster_arn, BrokerIds=broker_ids + ) assert response["ResponseMetadata"]["HTTPStatusCode"] == 200 @@ -38,18 +36,14 @@ def test_reboot_msk_broker_not_found(aws_client): client.exceptions = MagicMock() client.exceptions.NotFoundException = NotFoundException - client.reboot_broker.side_effect = NotFoundException( - "Cluster not found" - ) + client.reboot_broker.side_effect = NotFoundException("Cluster not found") expected_error_message = "The specified cluster was not found" with pytest.raises(FailedActivity) as exc_info: reboot_msk_broker(cluster_arn=cluster_arn, broker_ids=broker_ids) - assert expected_error_message in str( - exc_info.value - ) + assert expected_error_message in str(exc_info.value) @patch("chaosaws.msk.actions.aws_client", autospec=True) @@ -58,9 +52,7 @@ def test_delete_cluster_success(aws_client): aws_client.return_value = client cluster_arn = "arn_msk_cluster" client.delete_cluster.return_value = { - "ResponseMetadata": { - "HTTPStatusCode": 200 - } + "ResponseMetadata": {"HTTPStatusCode": 200} } response = delete_cluster(cluster_arn=cluster_arn) @@ -77,15 +69,11 @@ def test_delete_cluster_not_found(aws_client): client.exceptions = MagicMock() client.exceptions.NotFoundException = NotFoundException - client.delete_cluster.side_effect = NotFoundException( - "Cluster not found" - ) + client.delete_cluster.side_effect = NotFoundException("Cluster not found") expected_error_message = "The specified cluster was not found" with pytest.raises(FailedActivity) as exc_info: delete_cluster(cluster_arn=cluster_arn) - assert expected_error_message in str( - exc_info.value - ) \ No newline at end of file + assert expected_error_message in str(exc_info.value) diff --git a/tests/msk/test_msk_probes.py b/tests/msk/test_msk_probes.py index 8ed3e4c..432acdf 100644 --- a/tests/msk/test_msk_probes.py +++ b/tests/msk/test_msk_probes.py @@ -32,18 +32,14 @@ def test_describe_msk_cluster_not_found(aws_client): client.exceptions = MagicMock() client.exceptions.NotFoundException = NotFoundException - client.describe_cluster.side_effect = NotFoundException( - "Cluster not found" - ) + client.describe_cluster.side_effect = NotFoundException("Cluster not found") expected_error_message = "The specified cluster was not found" with pytest.raises(FailedActivity) as exc_info: describe_msk_cluster(cluster_arn=cluster_arn) - - assert expected_error_message in str( - exc_info.value - ) + + assert expected_error_message in str(exc_info.value) @patch("chaosaws.msk.probes.aws_client", autospec=True) @@ -79,6 +75,4 @@ def test_get_bootstrap_server_cluster_not_found(aws_client): with pytest.raises(FailedActivity) as exc_info: get_bootstrap_servers(cluster_arn=cluster_arn) - assert expected_error_message in str( - exc_info.value - ) + assert expected_error_message in str(exc_info.value)