#NEWLINE# @ mock . patch ( 'nova.objects.MigrationList.get_in_progress_by_host_and_node' ) #NEWLINE# @ mock . patch ( 'nova.objects.InstanceList.get_by_host_and_node' ) #NEWLINE# def test_instances_with_live_migrations( self , mock_instance_list , mock_migration_list ) : #NEWLINE# #INDENT# instance = self . _fake_instance_obj ( ) #NEWLINE# migration = objects . Migration ( context = instance . context , migration_type = 'live-migration' , instance_uuid = instance . uuid ) #NEWLINE# mock_migration_list . return_value = [ migration ] #NEWLINE# mock_instance_list . return_value = [ instance ] #NEWLINE# with mock . patch . object ( self . tracker , '_pair_instances_to_migrations' ) as mock_pair : #NEWLINE# #INDENT# self . tracker . update_available_resource ( self . context ) #NEWLINE# self . assertTrue ( mock_pair . called ) #NEWLINE# self . assertEqual ( instance . uuid , mock_pair . call_args_list [ 0 ] [ 0 ] [ 0 ] [ 0 ] . instance_uuid ) #NEWLINE# self . assertEqual ( instance . uuid , mock_pair . call_args_list [ 0 ] [ 0 ] [ 1 ] [ 0 ] . uuid ) #NEWLINE# self . assertEqual ( [ 'system_metadata' , 'numa_topology' , 'flavor' , 'migration_context' ] , mock_instance_list . call_args_list [ 0 ] [ 1 ] [ 'expected_attrs' ] ) #NEWLINE# #UNINDENT# self . assertEqual ( ( FAKE_VIRT_MEMORY_MB + FAKE_VIRT_MEMORY_OVERHEAD ) , self . tracker . compute_node . memory_mb_used ) #NEWLINE# self . assertEqual ( ( ROOT_GB + EPHEMERAL_GB ) , self . tracker . compute_node . local_gb_used ) #NEWLINE# mock_migration_list . assert_called_once_with ( self . context , 'fakehost' , 'fakenode' )