diff --git a/changelogs/fragments/20240107-refactor_ec2_ami-modules.yml b/changelogs/fragments/20240107-refactor_ec2_ami-modules.yml index 146e0bbd52f..14c8bc4da3a 100644 --- a/changelogs/fragments/20240107-refactor_ec2_ami-modules.yml +++ b/changelogs/fragments/20240107-refactor_ec2_ami-modules.yml @@ -1,3 +1,4 @@ --- minor_changes: - - ec2_ami - refactored code to use ``AnsibleEC2Error`` as well as moving shared code into module_utils.ec2 (https://github.com/ansible-collections/amazon.aws/pull/2164). - ec2_ami_info - refactored code to use ``AnsibleEC2Error`` as well as moving shared code into module_utils.ec2 (https://github.com/ansible-collections/amazon.aws/pull/2164). \ No newline at end of file + - ec2_ami - refactored code to use ``AnsibleEC2Error`` as well as moving shared code into module_utils.ec2 (https://github.com/ansible-collections/amazon.aws/pull/2164). + - ec2_ami_info - refactored code to use ``AnsibleEC2Error`` as well as moving shared code into module_utils.ec2 (https://github.com/ansible-collections/amazon.aws/pull/2164). diff --git a/tests/unit/plugins/modules/test_ec2_ami_info.py b/tests/unit/plugins/modules/test_ec2_ami_info.py index af202b8ccd8..087c55077cd 100644 --- a/tests/unit/plugins/modules/test_ec2_ami_info.py +++ b/tests/unit/plugins/modules/test_ec2_ami_info.py @@ -7,7 +7,6 @@ from unittest.mock import call from unittest.mock import patch -import botocore.exceptions import pytest from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict @@ -183,13 +182,14 @@ def test_main_success(m_AnsibleAWSModule): m_module.exit_json.assert_called_with(images=[]) -def a_boto_exception(): - return botocore.exceptions.UnknownServiceError(service_name="Whoops", known_service_names="Oula") +def a_ami_info_exception(): + return ec2_ami_info.AnsibleEC2Error(message="Whoops") -def test_api_failure_get_images(ec2_client): +@patch(module_name + ".describe_images") +def test_api_failure_get_images(m_describe_images): request_args = {} - ec2_client.describe_images.side_effect = a_boto_exception() + m_describe_images.side_effect = a_ami_info_exception() with pytest.raises(ec2_ami_info.AmiInfoFailure): ec2_ami_info.get_images(ec2_client, request_args)