diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/CMakeLists.txt b/Trigger/TrigHypothesis/TrigHLTJetHypo/CMakeLists.txt index 76dc1f7dc4e78f374b142d214051c01bcead28c9..ca4c689818665d08eddff43cdc45cc2a785332dc 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/CMakeLists.txt +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/CMakeLists.txt @@ -33,6 +33,9 @@ atlas_add_component( TrigHLTJetHypo INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} LINK_LIBRARIES ${ROOT_LIBRARIES} xAODJet GaudiKernel TrigParticle TrigSteeringEvent TrigInterfacesLib TrigTimeAlgsLib TrigHLTJetHypoLib DecisionHandlingLib ) +atlas_add_test( TrigHLTJetHypoTool SCRIPT python -m TrigHLTJetHypo.TrigJetHypoToolConfig + POST_EXEC_SCRIPT nopost.sh ) + # Install files from the package: atlas_install_python_modules( python/*.py ) diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py index 0f3709e1054747021edef741f85d76d2969febe3..538ed52e796f81595f6603c76ec0bd958d7eb434 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py @@ -24,17 +24,18 @@ def decodeEtEta(match, chain): return conf_tool +def trigJetHypoToolFromDict(chainDict): + return trigJetHypoToolFromName( chainDict['chainName'], chainDict['chainName']) + def trigJetHypoToolFromName(name, jetconfig): """Configure a jet hypo tool from chain name. Delegate to functions according to the hypo scenartio.""" - - scenario_dict = {re_EtEta0: decodeEtEta} chain = jetconfig for k, v in scenario_dict.items(): - match = k.match(chain) + match = k.match(chain) if match: hypo_tool = TrigJetHypoToolMT(chain) hypo_tool.HypoConfigurer = v(match, chain) @@ -43,19 +44,24 @@ def trigJetHypoToolFromName(name, jetconfig): msg = 'trigJetHypoToolFromName(%s) - decode error' % chain raise NotImplementedError(msg) - - +import unittest +class TestStringMethods(unittest.TestCase): + def testValidConfigs(self): + # EtaEt hypos + # from MC_pp_v7 import TriggerFlags.JetSlice.signatures + # exception or any other issue will make the ctest for this package fail + chains = ('HLT_j85', 'HLT_j35_320eta490') + wid = max(len(c) for c in chains) + for c in chains: + tool = trigJetHypoToolFromName(c, c) + self.assertIsNotNone( tool ) + print '%s' % c.rjust(wid), tool -if __name__ == '__main__': + def testInvalidConfig(self): + with self.assertRaises(NotImplementedError): + tool = trigJetHypoToolFromName('HLT_nonsense', 'HLT_nonsense') - # EtaEt hypos - # from MC_pp_v7 import TriggerFlags.JetSlice.signatures - chains = ('HLT_j85', 'HLT_j35_320eta490', 'HLT_nonsense') - wid = max(len(c) for c in chains) - for c in chains: - try: - print '%s' % c.rjust(wid), trigJetHypoToolFromName(c) - except Exception, e: - print e +if __name__ == '__main__': + unittest.main()