<s> """<STR_LIT>""" <EOL> import mock <EOL> from oslo_utils import importutils <EOL> import six <EOL> from six . moves import builtins as __builtin__ <EOL> import six . moves . urllib . parse as urlparse <EOL> if six . PY3 : <EOL> import io <EOL> file = io . BytesIO <EOL> from ironic . common import exception <EOL> from ironic . drivers . modules . ilo import common as ilo_common <EOL> from ironic . drivers . modules . ilo import firmware_processor as ilo_fw_processor <EOL> from ironic . tests import base <EOL> ilo_error = importutils . try_import ( '<STR_LIT>' ) <EOL> class FirmwareProcessorTestCase ( base . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( FirmwareProcessorTestCase , self ) . setUp ( ) <EOL> self . any_url = '<STR_LIT>' <EOL> self . fw_processor_fake = mock . MagicMock ( <EOL> parsed_url = '<STR_LIT>' ) <EOL> def test_verify_firmware_update_args_throws_for_invalid_update_mode ( self ) : <EOL> update_firmware_mock = mock . MagicMock ( ) <EOL> firmware_update_args = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : None } <EOL> update_firmware_mock . __name__ = '<STR_LIT>' <EOL> wrapped_func = ( ilo_fw_processor . <EOL> verify_firmware_update_args ( update_firmware_mock ) ) <EOL> node_fake = mock . MagicMock ( uuid = '<STR_LIT>' ) <EOL> task_fake = mock . MagicMock ( node = node_fake ) <EOL> self . assertRaises ( exception . InvalidParameterValue , <EOL> wrapped_func , <EOL> mock . ANY , <EOL> task_fake , <EOL> ** firmware_update_args ) <EOL> def test_verify_firmware_update_args_throws_for_no_firmware_url ( self ) : <EOL> update_firmware_mock = mock . MagicMock ( ) <EOL> firmware_update_args = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ ] } <EOL> update_firmware_mock . __name__ = '<STR_LIT>' <EOL> wrapped_func = ( ilo_fw_processor . <EOL> verify_firmware_update_args ( update_firmware_mock ) ) <EOL> self . assertRaises ( exception . InvalidParameterValue , <EOL> wrapped_func , <EOL> mock . ANY , <EOL> mock . ANY , <EOL> ** firmware_update_args ) <EOL> def test_get_and_validate_firmware_image_info ( self ) : <EOL> firmware_image_info = { <EOL> '<STR_LIT:url>' : self . any_url , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> url , checksum , component = ( <EOL> ilo_fw_processor . get_and_validate_firmware_image_info ( <EOL> firmware_image_info ) ) <EOL> self . assertEqual ( self . any_url , url ) <EOL> self . assertEqual ( '<STR_LIT>' , checksum ) <EOL> self . assertEqual ( '<STR_LIT>' , component ) <EOL> def test_get_and_validate_firmware_image_info_fails_for_missing_parameter ( <EOL> self ) : <EOL> invalid_firmware_image_info = { <EOL> '<STR_LIT:url>' : self . any_url , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> self . assertRaisesRegexp ( <EOL> exception . MissingParameterValue , '<STR_LIT>' , <EOL> ilo_fw_processor . get_and_validate_firmware_image_info , <EOL> invalid_firmware_image_info ) <EOL> def test_get_and_validate_firmware_image_info_fails_for_empty_parameter ( <EOL> self ) : <EOL> invalid_firmware_image_info = { <EOL> '<STR_LIT:url>' : self . any_url , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> self . assertRaisesRegexp ( <EOL> exception . MissingParameterValue , '<STR_LIT>' , <EOL> ilo_fw_processor . get_and_validate_firmware_image_info , <EOL> invalid_firmware_image_info ) <EOL> def test_get_and_validate_firmware_image_info_fails_for_invalid_component ( <EOL> self ) : <EOL> invalid_firmware_image_info = { <EOL> '<STR_LIT:url>' : self . any_url , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> self . assertRaises ( <EOL> exception . InvalidParameterValue , <EOL> ilo_fw_processor . get_and_validate_firmware_image_info , <EOL> invalid_firmware_image_info ) <EOL> def test_fw_processor_ctor_sets_parsed_url_attrib_of_fw_processor ( self ) : <EOL> fw_processor = ilo_fw_processor . FirmwareProcessor ( self . any_url ) <EOL> self . assertEqual ( self . any_url , fw_processor . parsed_url . geturl ( ) ) <EOL> @ mock . patch . object ( <EOL> ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test__download_file_based_fw_to_gets_invoked_for_file_based_firmware ( <EOL> self , _download_file_based_fw_to_mock ) : <EOL> some_file_url = '<STR_LIT>' <EOL> fw_processor = ilo_fw_processor . FirmwareProcessor ( some_file_url ) <EOL> fw_processor . _download_fw_to ( '<STR_LIT>' ) <EOL> _download_file_based_fw_to_mock . assert_called_once_with ( <EOL> fw_processor , '<STR_LIT>' ) <EOL> @ mock . patch . object ( <EOL> ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test__download_http_based_fw_to_gets_invoked_for_http_based_firmware ( <EOL> self , _download_http_based_fw_to_mock ) : <EOL> for some_http_url in ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) : <EOL> fw_processor = ilo_fw_processor . FirmwareProcessor ( some_http_url ) <EOL> fw_processor . _download_fw_to ( '<STR_LIT>' ) <EOL> _download_http_based_fw_to_mock . assert_called_once_with ( <EOL> fw_processor , '<STR_LIT>' ) <EOL> _download_http_based_fw_to_mock . reset_mock ( ) <EOL> @ mock . patch . object ( <EOL> ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test__download_swift_based_fw_to_gets_invoked_for_swift_based_firmware ( <EOL> self , _download_swift_based_fw_to_mock ) : <EOL> some_swift_url = '<STR_LIT>' <EOL> fw_processor = ilo_fw_processor . FirmwareProcessor ( some_swift_url ) <EOL> fw_processor . _download_fw_to ( '<STR_LIT>' ) <EOL> _download_swift_based_fw_to_mock . assert_called_once_with ( <EOL> fw_processor , '<STR_LIT>' ) <EOL> def test_fw_processor_ctor_throws_exception_with_invalid_firmware_url ( <EOL> self ) : <EOL> any_invalid_firmware_url = '<STR_LIT>' <EOL> self . assertRaises ( exception . InvalidParameterValue , <EOL> ilo_fw_processor . FirmwareProcessor , <EOL> any_invalid_firmware_url ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_common , '<STR_LIT>' , <EOL> spec_set = True , autospec = True ) <EOL> @ mock . patch . object ( <EOL> ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test_process_fw_on_calls__download_fw_to ( <EOL> self , _extract_fw_from_file_mock , verify_checksum_mock , <EOL> shutil_mock , os_mock , tempfile_mock ) : <EOL> fw_processor = ilo_fw_processor . FirmwareProcessor ( self . any_url ) <EOL> _download_fw_to_mock = mock . MagicMock ( ) <EOL> fw_processor . _download_fw_to = _download_fw_to_mock <EOL> expected_return_location = ( ilo_fw_processor . FirmwareImageLocation ( <EOL> '<STR_LIT>' , '<STR_LIT:file>' ) ) <EOL> _extract_fw_from_file_mock . return_value = ( expected_return_location , <EOL> True ) <EOL> node_mock = mock . ANY <EOL> checksum_fake = mock . ANY <EOL> actual_return_location = fw_processor . process_fw_on ( node_mock , <EOL> checksum_fake ) <EOL> _download_fw_to_mock . assert_called_once_with ( <EOL> os_mock . path . join . return_value ) <EOL> self . assertEqual ( expected_return_location . fw_image_location , <EOL> actual_return_location . fw_image_location ) <EOL> self . assertEqual ( expected_return_location . fw_image_filename , <EOL> actual_return_location . fw_image_filename ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_common , '<STR_LIT>' , <EOL> spec_set = True , autospec = True ) <EOL> @ mock . patch . object ( <EOL> ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test_process_fw_on_verifies_checksum_of_downloaded_fw_file ( <EOL> self , _extract_fw_from_file_mock , verify_checksum_mock , <EOL> shutil_mock , os_mock , tempfile_mock ) : <EOL> fw_processor = ilo_fw_processor . FirmwareProcessor ( self . any_url ) <EOL> _download_fw_to_mock = mock . MagicMock ( ) <EOL> fw_processor . _download_fw_to = _download_fw_to_mock <EOL> expected_return_location = ( ilo_fw_processor . FirmwareImageLocation ( <EOL> '<STR_LIT>' , '<STR_LIT:file>' ) ) <EOL> _extract_fw_from_file_mock . return_value = ( expected_return_location , <EOL> True ) <EOL> node_mock = mock . ANY <EOL> checksum_fake = mock . ANY <EOL> actual_return_location = fw_processor . process_fw_on ( node_mock , <EOL> checksum_fake ) <EOL> _download_fw_to_mock . assert_called_once_with ( <EOL> os_mock . path . join . return_value ) <EOL> verify_checksum_mock . assert_called_once_with ( <EOL> os_mock . path . join . return_value , checksum_fake ) <EOL> self . assertEqual ( expected_return_location . fw_image_location , <EOL> actual_return_location . fw_image_location ) <EOL> self . assertEqual ( expected_return_location . fw_image_filename , <EOL> actual_return_location . fw_image_filename ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_common , '<STR_LIT>' , <EOL> spec_set = True , autospec = True ) <EOL> def test_process_fw_on_throws_error_if_checksum_validation_fails ( <EOL> self , verify_checksum_mock , shutil_mock , os_mock , tempfile_mock ) : <EOL> fw_processor = ilo_fw_processor . FirmwareProcessor ( self . any_url ) <EOL> _download_fw_to_mock = mock . MagicMock ( ) <EOL> fw_processor . _download_fw_to = _download_fw_to_mock <EOL> verify_checksum_mock . side_effect = exception . ImageRefValidationFailed ( <EOL> image_href = '<STR_LIT>' , <EOL> reason = '<STR_LIT>' ) <EOL> node_mock = mock . ANY <EOL> checksum_fake = mock . ANY <EOL> self . assertRaises ( exception . ImageRefValidationFailed , <EOL> fw_processor . process_fw_on , <EOL> node_mock , <EOL> checksum_fake ) <EOL> shutil_mock . rmtree . assert_called_once_with ( <EOL> tempfile_mock . mkdtemp ( ) , ignore_errors = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_common , '<STR_LIT>' , <EOL> spec_set = True , autospec = True ) <EOL> @ mock . patch . object ( <EOL> ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test_process_fw_on_calls__extract_fw_from_file ( <EOL> self , _extract_fw_from_file_mock , verify_checksum_mock , <EOL> shutil_mock , os_mock , tempfile_mock ) : <EOL> fw_processor = ilo_fw_processor . FirmwareProcessor ( self . any_url ) <EOL> _download_fw_to_mock = mock . MagicMock ( ) <EOL> fw_processor . _download_fw_to = _download_fw_to_mock <EOL> expected_return_location = ( ilo_fw_processor . FirmwareImageLocation ( <EOL> '<STR_LIT>' , '<STR_LIT:file>' ) ) <EOL> _extract_fw_from_file_mock . return_value = ( expected_return_location , <EOL> True ) <EOL> node_mock = mock . ANY <EOL> checksum_fake = mock . ANY <EOL> actual_return_location = fw_processor . process_fw_on ( node_mock , <EOL> checksum_fake ) <EOL> _extract_fw_from_file_mock . assert_called_once_with ( <EOL> node_mock , os_mock . path . join . return_value ) <EOL> self . assertEqual ( expected_return_location . fw_image_location , <EOL> actual_return_location . fw_image_location ) <EOL> self . assertEqual ( expected_return_location . fw_image_filename , <EOL> actual_return_location . fw_image_filename ) <EOL> shutil_mock . rmtree . assert_called_once_with ( <EOL> tempfile_mock . mkdtemp ( ) , ignore_errors = True ) <EOL> @ mock . patch . object ( __builtin__ , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( <EOL> ilo_fw_processor . image_service , '<STR_LIT>' , autospec = True ) <EOL> def test__download_file_based_fw_to_copies_file_to_target ( <EOL> self , file_image_service_mock , open_mock ) : <EOL> fd_mock = mock . MagicMock ( spec = file ) <EOL> open_mock . return_value = fd_mock <EOL> fd_mock . __enter__ . return_value = fd_mock <EOL> any_file_based_firmware_file = '<STR_LIT>' <EOL> firmware_file_path = '<STR_LIT>' <EOL> self . fw_processor_fake . parsed_url = urlparse . urlparse ( <EOL> any_file_based_firmware_file ) <EOL> ilo_fw_processor . _download_file_based_fw_to ( self . fw_processor_fake , <EOL> '<STR_LIT>' ) <EOL> file_image_service_mock . return_value . download . assert_called_once_with ( <EOL> firmware_file_path , fd_mock ) <EOL> @ mock . patch . object ( __builtin__ , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test__download_http_based_fw_to_downloads_the_fw_file ( <EOL> self , image_service_mock , open_mock ) : <EOL> fd_mock = mock . MagicMock ( spec = file ) <EOL> open_mock . return_value = fd_mock <EOL> fd_mock . __enter__ . return_value = fd_mock <EOL> any_http_based_firmware_file = '<STR_LIT>' <EOL> any_target_file = '<STR_LIT>' <EOL> self . fw_processor_fake . parsed_url = urlparse . urlparse ( <EOL> any_http_based_firmware_file ) <EOL> ilo_fw_processor . _download_http_based_fw_to ( self . fw_processor_fake , <EOL> any_target_file ) <EOL> image_service_mock . HttpImageService ( ) . download . assert_called_once_with ( <EOL> any_http_based_firmware_file , fd_mock ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( <EOL> ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test__download_swift_based_fw_to_creates_temp_url ( <EOL> self , swift_mock , _download_http_based_fw_to_mock , urlparse_mock ) : <EOL> any_swift_based_firmware_file = '<STR_LIT>' <EOL> any_target_file = '<STR_LIT>' <EOL> self . fw_processor_fake . parsed_url = urlparse . urlparse ( <EOL> any_swift_based_firmware_file ) <EOL> ilo_fw_processor . _download_swift_based_fw_to ( self . fw_processor_fake , <EOL> any_target_file ) <EOL> swift_mock . SwiftAPI ( ) . get_temp_url . assert_called_once_with ( <EOL> '<STR_LIT>' , '<STR_LIT>' , mock . ANY ) <EOL> @ mock . patch . object ( urlparse , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( <EOL> ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test__download_swift_based_fw_to_calls__download_http_based_fw_to ( <EOL> self , swift_mock , _download_http_based_fw_to_mock , urlparse_mock ) : <EOL> """<STR_LIT>""" <EOL> any_swift_based_firmware_file = '<STR_LIT>' <EOL> any_target_file = '<STR_LIT>' <EOL> self . fw_processor_fake . parsed_url = urlparse . urlparse ( <EOL> any_swift_based_firmware_file ) <EOL> urlparse_mock . reset_mock ( ) <EOL> ilo_fw_processor . _download_swift_based_fw_to ( self . fw_processor_fake , <EOL> any_target_file ) <EOL> _download_http_based_fw_to_mock . assert_called_once_with ( <EOL> self . fw_processor_fake , any_target_file ) <EOL> urlparse_mock . assert_called_once_with ( <EOL> swift_mock . SwiftAPI ( ) . get_temp_url . return_value ) <EOL> self . assertEqual ( <EOL> urlparse_mock . return_value , self . fw_processor_fake . parsed_url ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test__extract_fw_from_file_calls_process_firmware_image ( <EOL> self , utils_mock , ilo_common_mock ) : <EOL> node_mock = mock . MagicMock ( uuid = '<STR_LIT>' ) <EOL> any_target_file = '<STR_LIT>' <EOL> ilo_object_mock = ilo_common_mock . get_ilo_object . return_value <EOL> utils_mock . process_firmware_image . return_value = ( '<STR_LIT>' , <EOL> True , True ) <EOL> ilo_fw_processor . _extract_fw_from_file ( node_mock , any_target_file ) <EOL> utils_mock . process_firmware_image . assert_called_once_with ( <EOL> any_target_file , ilo_object_mock ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test__extract_fw_from_file_doesnt_upload_firmware ( <EOL> self , utils_mock , ilo_common_mock ) : <EOL> node_mock = mock . MagicMock ( uuid = '<STR_LIT>' ) <EOL> any_target_file = '<STR_LIT>' <EOL> utils_mock . process_firmware_image . return_value = ( <EOL> '<STR_LIT>' , False , True ) <EOL> ilo_fw_processor . _extract_fw_from_file ( node_mock , any_target_file ) <EOL> ilo_common_mock . copy_image_to_web_server . assert_not_called ( ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , <EOL> autospec = True ) <EOL> def test__extract_fw_from_file_sets_loc_obj_remove_to_file_if_no_upload ( <EOL> self , _remove_mock , utils_mock , ilo_common_mock ) : <EOL> node_mock = mock . MagicMock ( uuid = '<STR_LIT>' ) <EOL> any_target_file = '<STR_LIT>' <EOL> utils_mock . process_firmware_image . return_value = ( <EOL> '<STR_LIT>' , False , True ) <EOL> location_obj , is_different_file = ( <EOL> ilo_fw_processor . _extract_fw_from_file ( node_mock , any_target_file ) ) <EOL> location_obj . remove ( ) <EOL> _remove_mock . assert_called_once_with ( location_obj ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test__extract_fw_from_file_uploads_firmware_to_webserver ( <EOL> self , utils_mock , ilo_common_mock ) : <EOL> node_mock = mock . MagicMock ( uuid = '<STR_LIT>' ) <EOL> any_target_file = '<STR_LIT>' <EOL> utils_mock . process_firmware_image . return_value = ( <EOL> '<STR_LIT>' , True , True ) <EOL> self . config ( use_web_server_for_images = True , group = '<STR_LIT>' ) <EOL> ilo_fw_processor . _extract_fw_from_file ( node_mock , any_target_file ) <EOL> ilo_common_mock . copy_image_to_web_server . assert_called_once_with ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , <EOL> autospec = True ) <EOL> def test__extract_fw_from_file_sets_loc_obj_remove_to_webserver ( <EOL> self , _remove_mock , utils_mock , ilo_common_mock ) : <EOL> node_mock = mock . MagicMock ( uuid = '<STR_LIT>' ) <EOL> any_target_file = '<STR_LIT>' <EOL> utils_mock . process_firmware_image . return_value = ( <EOL> '<STR_LIT>' , True , True ) <EOL> self . config ( use_web_server_for_images = True , group = '<STR_LIT>' ) <EOL> location_obj , is_different_file = ( <EOL> ilo_fw_processor . _extract_fw_from_file ( node_mock , any_target_file ) ) <EOL> location_obj . remove ( ) <EOL> _remove_mock . assert_called_once_with ( location_obj ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test__extract_fw_from_file_uploads_firmware_to_swift ( <EOL> self , utils_mock , ilo_common_mock ) : <EOL> node_mock = mock . MagicMock ( uuid = '<STR_LIT>' ) <EOL> any_target_file = '<STR_LIT>' <EOL> utils_mock . process_firmware_image . return_value = ( <EOL> '<STR_LIT>' , True , True ) <EOL> self . config ( use_web_server_for_images = False , group = '<STR_LIT>' ) <EOL> ilo_fw_processor . _extract_fw_from_file ( node_mock , any_target_file ) <EOL> ilo_common_mock . copy_image_to_swift . assert_called_once_with ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , <EOL> autospec = True ) <EOL> def test__extract_fw_from_file_sets_loc_obj_remove_to_swift ( <EOL> self , _remove_mock , utils_mock , ilo_common_mock ) : <EOL> node_mock = mock . MagicMock ( uuid = '<STR_LIT>' ) <EOL> any_target_file = '<STR_LIT>' <EOL> utils_mock . process_firmware_image . return_value = ( <EOL> '<STR_LIT>' , True , True ) <EOL> self . config ( use_web_server_for_images = False , group = '<STR_LIT>' ) <EOL> location_obj , is_different_file = ( <EOL> ilo_fw_processor . _extract_fw_from_file ( node_mock , any_target_file ) ) <EOL> location_obj . remove ( ) <EOL> _remove_mock . assert_called_once_with ( location_obj ) <EOL> def test_fw_img_loc_sets_these_attributes ( self ) : <EOL> any_loc = '<STR_LIT>' <EOL> any_s_filename = '<STR_LIT>' <EOL> location_obj = ilo_fw_processor . FirmwareImageLocation ( <EOL> any_loc , any_s_filename ) <EOL> self . assertEqual ( any_loc , location_obj . fw_image_location ) <EOL> self . assertEqual ( any_s_filename , location_obj . fw_image_filename ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test__remove_file_based_me ( <EOL> self , ilo_common_mock ) : <EOL> fw_img_location_obj_fake = mock . MagicMock ( ) <EOL> ilo_fw_processor . _remove_file_based_me ( fw_img_location_obj_fake ) <EOL> ( ilo_common_mock . remove_single_or_list_of_files . <EOL> assert_called_with ( fw_img_location_obj_fake . fw_image_location ) ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test__remove_swift_based_me ( self , ilo_common_mock ) : <EOL> fw_img_location_obj_fake = mock . MagicMock ( ) <EOL> ilo_fw_processor . _remove_swift_based_me ( fw_img_location_obj_fake ) <EOL> ( ilo_common_mock . remove_image_from_swift . assert_called_with ( <EOL> fw_img_location_obj_fake . fw_image_filename , "<STR_LIT>" ) ) <EOL> @ mock . patch . object ( ilo_fw_processor , '<STR_LIT>' , autospec = True ) <EOL> def test__remove_webserver_based_me ( self , ilo_common_mock ) : <EOL> fw_img_location_obj_fake = mock . MagicMock ( ) <EOL> ilo_fw_processor . _remove_webserver_based_me ( fw_img_location_obj_fake ) <EOL> ( ilo_common_mock . remove_image_from_web_server . assert_called_with ( <EOL> fw_img_location_obj_fake . fw_image_filename ) ) </s>
