#NEWLINE# @ mock . patch . object ( db , 'block_device_mapping_get_by_instance_and_volume_id' ) #NEWLINE# def test_test_get_by_instance_and_volume_id_with_expected( self , mock_get ) : #NEWLINE# #INDENT# fake_inst = fake_instance . fake_db_instance ( ) #NEWLINE# mock_get . return_value = self . fake_bdm ( fake_inst ) #NEWLINE# obj_bdm = objects . BlockDeviceMapping #NEWLINE# vol_bdm = obj_bdm . get_by_volume_and_instance ( vol_bdm . context , 'fake-volume-id' , fake_inst [ 'uuid' ] , expected_attrs = [ 'instance' ] ) #NEWLINE# for attr in block_device_obj . BLOCK_DEVICE_OPTIONAL_ATTRS : #NEWLINE# #INDENT# self . assertTrue ( vol_bdm . obj_attr_is_set ( attr ) ) #NEWLINE# #UNINDENT# mock_get . assert_called_once_with ( self . context , 'fake-volume-id' , fake_inst [ 'uuid' ] , [ 'instance' ] )