#NEWLINE# @ mock . patch ( 'nova_solverscheduler.scheduler.solvers.utils.aggregate_values_from_key' ) #NEWLINE# def test_get_constraint_matrix( self , agg_mock ) : #NEWLINE# #INDENT# self . flags ( cpu_allocation_ratio = 1.0 ) #NEWLINE# def _agg_mock_side_effect( * args , **kwargs ) : #NEWLINE# #INDENT# if ( args [ 0 ] . host == 'host1' ) : #NEWLINE# #INDENT# return set ( [ '1.0' , '2.0' ] ) #NEWLINE# #UNINDENT# if ( args [ 0 ] . host == 'host2' ) : #NEWLINE# #INDENT# return set ( [ '3.0' ] ) #NEWLINE# #UNINDENT# if ( args [ 0 ] . host == 'host3' ) : #NEWLINE# #INDENT# return set ( [ ] ) #NEWLINE# #UNINDENT# #UNINDENT# agg_mock . side_effect = _agg_mock_side_effect #NEWLINE# expected_cons_mat = [ [ False , False ] , [ True , True ] , [ False , False ] ] #NEWLINE# cons_mat = self . constraint_cls ( ) . get_constraint_matrix ( self . fake_hosts , _agg_mock_side_effect . fake_filter_properties ) #NEWLINE# agg_mock . assert_any_call ( self . fake_hosts [ 0 ] , 'cpu_allocation_ratio' ) #NEWLINE# agg_mock . assert_any_call ( self . fake_hosts [ 1 ] , 'cpu_allocation_ratio' ) #NEWLINE# agg_mock . assert_any_call ( self . fake_hosts [ 2 ] , 'cpu_allocation_ratio' ) #NEWLINE# self . assertEqual ( expected_cons_mat , cons_mat )