#NEWLINE# def test_same_rack_with_cross_rack_host( self , racks_mock ) : #NEWLINE# #INDENT# instance = objects . Instance ( uuid = 'inst1' ) #NEWLINE# instance_uuid = instance . uuid #NEWLINE# self . fake_hosts [ 0 ] . instances = { #NEWLINE# #INDENT# instance_uuid : instance , #NEWLINE# #UNINDENT# } #NEWLINE# fake_filter_properties = { #NEWLINE# #INDENT# 'context' : self . context , #NEWLINE# 'project_id' : 'fake' , #NEWLINE# 'num_instances' : 2 , #NEWLINE# 'scheduler_hints' : { #NEWLINE# #INDENT# 'same_rack' : instance_uuid , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# racks_mock . return_value = { #NEWLINE# #INDENT# 'host1' : set ( [ 'rack1' , 'rack2' ] ) , #NEWLINE# 'host2' : set ( [ 'rack1' ] ) , #NEWLINE# 'host3' : set ( [ 'rack2' ] ) , #NEWLINE# 'host4' : set ( [ 'rack2' ] ) , #NEWLINE# 'host5' : set ( [ 'rack3' ] ) , #NEWLINE# 'host6' : set ( [ 'rack3' ] ) , #NEWLINE# #UNINDENT# } #NEWLINE# expected_cons_mat = [ [ True , True ] , [ True , True ] , [ True , True ] , [ True , True ] , [ False , False ] , [ False , False ] ] #NEWLINE# cons_mat = self . constraint_cls ( ) . get_constraint_matrix ( self . fake_hosts , fake_filter_properties ) #NEWLINE# self . assertEqual ( expected_cons_mat , cons_mat )