def test_cloudwatch_delete_rule(aws_client): client = MagicMock() aws_client.return_value = client rule_name = "my-rule" delete_rule(rule_name) client.delete_rule.assert_called_with(Name=rule_name) client.remove_targets.assert_not_called()
def test_cloudwatch_delete_rule_force(aws_client): client = MagicMock() aws_client.return_value = client target_ids = ['1', '2', '3'] client.list_targets_by_rule.return_value = { 'Targets': [{'Id': t} for t in target_ids] } rule_name = 'my-rule' delete_rule(rule_name, force=True) client.delete_rule.assert_called_with(Name=rule_name) client.list_targets_by_rule.assert_called_with(Rule=rule_name) client.remove_targets.assert_called_with(Rule=rule_name, Ids=target_ids)
def test_cloudwatch_delete_rule_force(aws_client): client = MagicMock() aws_client.return_value = client target_ids = ["1", "2", "3"] client.list_targets_by_rule.return_value = { "Targets": [{ "Id": t } for t in target_ids] } rule_name = "my-rule" delete_rule(rule_name, force=True) client.delete_rule.assert_called_with(Name=rule_name) client.list_targets_by_rule.assert_called_with(Rule=rule_name) client.remove_targets.assert_called_with(Rule=rule_name, Ids=target_ids)