#NEWLINE# @ mock . patch . object ( resource_tracker . ResourceTracker , '_update_usage_from_migration' ) #NEWLINE# @ mock . patch ( 'nova.objects.instance.Instance.get_by_uuid' ) #NEWLINE# def test_flavor_not_found( self , mock_get_instance , mock_update_usage ) : #NEWLINE# #INDENT# mock_update_usage . side_effect = exception . FlavorNotFound ( flavor_id = '' ) #NEWLINE# instance = self . _fake_instance_obj ( ) #NEWLINE# mock_get_instance . return_value = instance #NEWLINE# migration = objects . Migration ( context = self . context , instance_uuid = instance . uuid ) #NEWLINE# self . tracker . _update_usage_from_migrations ( self . context , [ migration ] ) #NEWLINE# mock_get_instance . assert_called_once_with ( self . context , instance . uuid ) #NEWLINE# mock_update_usage . assert_called_once_with ( self . context , instance , None , migration )