def test__extract_fw_from_file_doesnt_upload_firmware( self, utils_mock, ilo_common_mock): # | GIVEN | node_mock = mock.MagicMock(uuid='fake_node_uuid') any_target_file = 'any_target_file' utils_mock.process_firmware_image.return_value = ( 'some_location/some_fw_file', False, True) # | WHEN | ilo_fw_processor._extract_fw_from_file(node_mock, any_target_file) # | THEN | ilo_common_mock.copy_image_to_web_server.assert_not_called()
def test__extract_fw_from_file_uploads_firmware_to_swift( self, utils_mock, ilo_common_mock): # | GIVEN | node_mock = mock.MagicMock(uuid='fake_node_uuid') any_target_file = 'any_target_file' utils_mock.process_firmware_image.return_value = ( 'some_location/some_fw_file', True, True) self.config(use_web_server_for_images=False, group='ilo') # | WHEN | ilo_fw_processor._extract_fw_from_file(node_mock, any_target_file) # | THEN | ilo_common_mock.copy_image_to_swift.assert_called_once_with( 'some_location/some_fw_file', 'some_fw_file')
def test__extract_fw_from_file_calls_process_firmware_image( self, utils_mock, ilo_common_mock): # | GIVEN | node_mock = mock.MagicMock(uuid='fake_node_uuid') any_target_file = 'any_target_file' ilo_object_mock = ilo_common_mock.get_ilo_object.return_value utils_mock.process_firmware_image.return_value = ('some_location', True, True) # | WHEN | ilo_fw_processor._extract_fw_from_file(node_mock, any_target_file) # | THEN | utils_mock.process_firmware_image.assert_called_once_with( any_target_file, ilo_object_mock)
def test__extract_fw_from_file_sets_loc_obj_remove_to_file_if_no_upload( self, _remove_mock, utils_mock, ilo_common_mock): # | GIVEN | node_mock = mock.MagicMock(uuid='fake_node_uuid') any_target_file = 'any_target_file' utils_mock.process_firmware_image.return_value = ( 'some_location/some_fw_file', False, True) # | WHEN | location_obj, is_different_file = ( ilo_fw_processor._extract_fw_from_file(node_mock, any_target_file)) location_obj.remove() # | THEN | _remove_mock.assert_called_once_with(location_obj)
def test__extract_fw_from_file_sets_loc_obj_remove_to_swift( self, _remove_mock, utils_mock, ilo_common_mock): # | GIVEN | node_mock = mock.ANY any_target_file = 'any_target_file' utils_mock.process_firmware_image.return_value = ( 'some_location/some_fw_file', True, True) self.config(use_web_server_for_images=False, group='ilo') # | WHEN | location_obj, is_different_file = ( ilo_fw_processor._extract_fw_from_file(node_mock, any_target_file)) location_obj.remove() # | THEN | _remove_mock.assert_called_once_with(location_obj)