#NEWLINE# @ mock . patch . object ( FAKE_CLIENT . node , 'set_provision_state' ) #NEWLINE# @ mock . patch . object ( ironic_driver . IronicDriver , '_add_driver_fields' ) #NEWLINE# @ mock . patch . object ( FAKE_CLIENT . node , 'get' ) #NEWLINE# @ mock . patch . object ( objects . Instance , 'save' ) #NEWLINE# def test_rebuild_failures( self , mock_save , mock_get , mock_driver_fields , mock_set_pstate ) : #NEWLINE# #INDENT# node_uuid = uuidutils . generate_uuid ( ) #NEWLINE# node = ironic_utils . get_test_node ( uuid = node_uuid , instance_uuid = self . instance_uuid , instance_type_id = 5 ) #NEWLINE# mock_get . return_value = node #NEWLINE# image_meta = ironic_utils . get_test_image_meta ( ) #NEWLINE# flavor_id = 5 #NEWLINE# flavor = objects . Flavor ( flavor_id = flavor_id , name = 'baremetal' ) #NEWLINE# instance = fake_instance . fake_instance_obj ( self . ctx , uuid = self . instance_uuid , node = node_uuid , instance_type_id = flavor_id ) #NEWLINE# instance . flavor = flavor #NEWLINE# exceptions = [ exception . NovaException ( ) , ironic_exception . BadRequest ( ) , ironic_exception . InternalServerError ( ) ] #NEWLINE# for e in exceptions : #NEWLINE# #INDENT# mock_set_pstate . side_effect = e #NEWLINE# self . assertRaises ( exception . InstanceDeployFailure , self . driver . rebuild , context = self . ctx , instance = instance , image_meta = image_meta , injected_files = None , admin_password = None , bdms = None , detach_block_devices = None , attach_block_devices = None )