#NEWLINE# @ mock . patch . object ( resource_tracker . ResourceTracker , '_update_usage_from_migration' ) #NEWLINE# @ mock . patch ( 'nova.objects.instance.Instance.get_by_uuid' ) #NEWLINE# def test_use_most_recent( self , mock_get_instance , mock_update_usage ) : #NEWLINE# #INDENT# instance = self . _fake_instance_obj ( ) #NEWLINE# mock_get_instance . return_value = instance #NEWLINE# migration_2002 = objects . Migration ( id = 2002 , context = self . context , instance_uuid = instance . uuid , updated_at = datetime . datetime ( 2002 , 1 , 1 , 0 , 0 , 0 ) ) #NEWLINE# migration_2003 = objects . Migration ( id = 2003 , context = self . context , instance_uuid = instance . uuid , updated_at = datetime . datetime ( 2003 , 1 , 1 , 0 , 0 , 0 ) ) #NEWLINE# migration_2001 = objects . Migration ( id = 2001 , context = self . context , instance_uuid = instance . uuid , updated_at = datetime . datetime ( 2001 , 1 , 1 , 0 , 0 , 0 ) ) #NEWLINE# self . tracker . _update_usage_from_migrations ( self . context , [ migration_2002 , migration_2003 , migration_2001 ] ) #NEWLINE# mock_get_instance . assert_called_once_with ( self . context , instance . uuid ) #NEWLINE# mock_update_usage . assert_called_once_with ( migration_2003 . context , instance , None , migration_2003 )