def test_Selection_outputLocation_with_no_branch_and_no_extension(): alg = MockConfGenerator() sel = Selection('SelOutputTest4', ConfGenerator=alg, OutputBranch='', Extension='') assert sel.outputLocation() == 'SelOutputTest4' assert sel.outputLocation() == sel.algorithm().Output
def test_Selection_output_data_setter(): alg = MockConfGenerator() sel0 = AutomaticData('Phys/Hello/World/0') sel1 = AutomaticData('Phys/Hello/World/1') sel = Selection('SelOutputTest6', ConfGenerator=alg, RequiredSelections=[sel0, sel1]) assert sel.algorithm().Output == sel.outputLocation()
def test_Selection_outputLocation_with_user_defined_extension_and_no_branch(): alg = MockConfGenerator() sel = Selection('SelOutputTest3', ConfGenerator=alg, OutputBranch='', Extension='Tracks') assert sel.outputLocation() == 'SelOutputTest3/Tracks' assert sel.outputLocation() == sel.algorithm().Output
def test_Selection_with_user_defined_output_data_setter(): alg = MockConfGenerator() sel0 = AutomaticData('Phys/Hello/World/0') sel1 = AutomaticData('Phys/Hello/World/1') sel = Selection('SelOutputTest8', ConfGenerator=alg, RequiredSelections=[sel0, sel1], OutputDataSetter='TESTOUTPUTS') assert sel.algorithm().TESTOUTPUTS == sel.outputLocation()
def test_Selection_does_not_modify_generator(): alg = MockConfGenerator() sel0 = AutomaticData('Phys/Hello/World/0') sel1 = AutomaticData('Phys/Hello/World/1') sel = Selection('SelGenTest', ConfGenerator=alg, RequiredSelections=[sel0, sel1]) assert sel.algorithm().Inputs == [ sel0.outputLocation(), sel1.outputLocation() ] assert hasattr(alg, 'Output') == False
class SelectionTree(object): sel000 = Selection('0.00000', ConfGenerator=MockConfGenerator(), RequiredSelections=[]) sel001 = Selection('0.00001', ConfGenerator=MockConfGenerator(), RequiredSelections=[]) sel002 = Selection('0.00002', ConfGenerator=MockConfGenerator(), RequiredSelections=[]) sel003 = Selection('0.00003', ConfGenerator=MockConfGenerator(), RequiredSelections=[]) sel100 = Selection('1.00000', ConfGenerator=MockConfGenerator(), RequiredSelections=[sel000, sel001]) sel101 = Selection('1.00001', ConfGenerator=MockConfGenerator(), RequiredSelections=[sel002, sel003]) sel200 = Selection('2.00000', ConfGenerator=MockConfGenerator(), RequiredSelections=[sel100, sel101]) algos = flatAlgorithmList(sel200) alg_names = [a.name() for a in algos]
def test_flatAlgorithmList_order_line(): sel000 = Selection('0.0000', ConfGenerator=MockConfGenerator(), RequiredSelections=[]) sel001 = Selection('0.0001', ConfGenerator=MockConfGenerator(), RequiredSelections=[sel000]) sel101 = Selection('1.0000', ConfGenerator=MockConfGenerator(), RequiredSelections=[sel001]) sel102 = Selection('1.0001', ConfGenerator=MockConfGenerator(), RequiredSelections=[sel101]) sel203 = Selection('2.0000', ConfGenerator=MockConfGenerator(), RequiredSelections=[sel102]) algos = flatAlgorithmList(sel203) assert [a.name() for a in algos ] == ['0.0000', '0.0001', '1.0000', '1.0001', '2.0000']
def test_flatAlgorithmList_removes_duplicates(): sel000 = SelectionTree.sel000 sel001 = SelectionTree.sel001 sel002 = SelectionTree.sel002 sel003 = SelectionTree.sel003 sel100 = Selection('1.10000', ConfGenerator=MockConfGenerator(), RequiredSelections=[sel000, sel001, sel002]) sel101 = Selection('1.10001', ConfGenerator=MockConfGenerator(), RequiredSelections=[sel001, sel002, sel003]) sel200 = Selection('2.10000', ConfGenerator=MockConfGenerator(), RequiredSelections=[sel100, sel101]) algos = flatAlgorithmList(sel200) alg_names = [a.name() for a in algos] assert len(algos) == 7 assert alg_names.count('0.00000') == 1 assert alg_names.count('0.00001') == 1 assert alg_names.count('0.00002') == 1 assert alg_names.count('0.00003') == 1 assert alg_names.count('1.10000') == 1 assert alg_names.count('1.10001') == 1 assert alg_names.count('2.10000') == 1 assert alg_names.index('0.00000') < alg_names.index('1.10000') assert alg_names.index('0.00001') < alg_names.index('1.10000') assert alg_names.index('0.00002') < alg_names.index('1.10000') assert alg_names.index('0.00001') < alg_names.index('1.10001') assert alg_names.index('0.00002') < alg_names.index('1.10001') assert alg_names.index('0.00003') < alg_names.index('1.10001') assert alg_names.index('1.10000') < alg_names.index('2.10000') assert alg_names.index('1.10001') < alg_names.index('2.10000')
def test_Selection_outputLocation(): alg = MockConfGenerator() sel = Selection('SelOutputTest0', ConfGenerator=alg) assert sel.outputLocation() == 'Phys/SelOutputTest0/Particles' assert sel.outputLocation() == sel.algorithm().Output
def test_Selection_name(): alg = MockConfGenerator() sel = Selection('SelNameTest', ConfGenerator=alg) assert sel.name() == 'SelNameTest'
def test_Selection_duplicate_name_raises(): alg = MockConfGenerator() sel = Selection('SelUniqueNameTest', ConfGenerator=alg) raises(NameError, Selection, 'SelUniqueNameTest', ConfGenerator=alg)