<s> import mock <EOL> from nova . pci import stats as pci_stats <EOL> from nova import test <EOL> from nova_solverscheduler . scheduler . solvers . constraints import pci_passthrough_constraint <EOL> from nova_solverscheduler . tests . scheduler import solver_scheduler_fakes as fakes <EOL> class TestPciPassthroughConstraint ( test . NoDBTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestPciPassthroughConstraint , self ) . setUp ( ) <EOL> self . constraint_cls = pci_passthrough_constraint . PciPassthroughConstraint <EOL> self . _generate_fake_constraint_input ( ) <EOL> def _generate_fake_constraint_input ( self ) : <EOL> requests = [ { '<STR_LIT:count>' : <NUM_LIT:1> , '<STR_LIT>' : [ { '<STR_LIT>' : '<STR_LIT>' } ] } ] <EOL> self . fake_filter_properties = { <EOL> '<STR_LIT>' : requests , <EOL> '<STR_LIT>' : [ '<STR_LIT>' % x for x in range ( <NUM_LIT:2> ) ] , <EOL> '<STR_LIT>' : <NUM_LIT:2> } <EOL> host1 = fakes . FakeSolverSchedulerHostState ( '<STR_LIT>' , '<STR_LIT>' , <EOL> { '<STR_LIT>' : pci_stats . PciDeviceStats ( ) } ) <EOL> host2 = fakes . FakeSolverSchedulerHostState ( '<STR_LIT>' , '<STR_LIT>' , <EOL> { '<STR_LIT>' : pci_stats . PciDeviceStats ( ) } ) <EOL> host3 = fakes . FakeSolverSchedulerHostState ( '<STR_LIT>' , '<STR_LIT>' , <EOL> { '<STR_LIT>' : pci_stats . PciDeviceStats ( ) } ) <EOL> self . fake_hosts = [ host1 , host2 , host3 ] <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_get_constraint_matrix ( self , apl_reqs , spt_reqs ) : <EOL> spt_reqs . side_effect = [ True , False ] + [ False ] + [ True , True , False ] <EOL> expected_cons_mat = [ <EOL> [ True , False ] , <EOL> [ False , False ] , <EOL> [ True , True ] ] <EOL> cons_mat = self . constraint_cls ( ) . get_constraint_matrix ( <EOL> self . fake_hosts , self . fake_filter_properties ) <EOL> self . assertEqual ( expected_cons_mat , cons_mat ) </s>
