def testEmpty(self): mgr = DAQPool() runset = mgr.findRunset(1) self.failIf(runset is not None, 'Found set in empty manager') mgr.remove(MockComponent('foo', 0))
def testBuildMissingOneOutput(self): mgr = DAQPool() compList = [] comp = MockComponent('fooHub', 0) comp.addOutput('aaa') comp.addInput('xxx', 123) compList.append(comp) comp = MockComponent('bar', 0) comp.addInput('aaa', 456) compList.append(comp) self.assertEqual(len(mgr.pool), 0) nameList = [] for c in compList: mgr.add(c) nameList.append(c.name) self.assertEqual(len(mgr.pool), len(compList)) logger = MockLogger('main') self.assertRaises(ValueError, mgr.makeRunset, nameList, logger) self.assertEqual(len(mgr.pool), len(compList)) for c in compList: mgr.remove(c) self.assertEqual(len(mgr.pool), 0) logger.checkStatus(10)
def testAddRemove(self): mgr = DAQPool() compList = [] comp = MockComponent('foo', 0) compList.append(comp) comp = MockComponent('bar', 0) compList.append(comp) self.assertEqual(mgr.numUnused(), 0) self.assertEqual(mgr.numComponents(), 0) for c in compList: mgr.add(c) self.assertEqual(mgr.numUnused(), len(compList)) self.assertEqual(mgr.numComponents(), len(compList)) for c in compList: mgr.remove(c) self.assertEqual(mgr.numUnused(), 0) self.assertEqual(mgr.numComponents(), 0)
def testBuildMultiMissing(self): mgr = DAQPool() compList = [] comp = MockComponent('fooHub', 0) comp.addInput('xxx', 123) compList.append(comp) comp = MockComponent('bar', 0) comp.addOutput('xxx') compList.append(comp) comp = MockComponent('feeHub', 0) comp.addInput('xxx', 456) compList.append(comp) comp = MockComponent('baz', 0) comp.addOutput('xxx') compList.append(comp) self.assertEqual(len(mgr.pool), 0) nameList = [] for c in compList: mgr.add(c) nameList.append(c.name) self.assertEqual(len(mgr.pool), len(compList)) logger = MockLogger('main') try: mgr.makeRunset(nameList, logger) self.fail('Unexpected success') except ValueError: pass except: self.fail('Unexpected exception') self.assertEqual(len(mgr.pool), len(compList)) for c in compList: mgr.remove(c) self.assertEqual(len(mgr.pool), 0) logger.checkStatus(10)
def testBuildMultiInput(self): mgr = DAQPool() compList = [] comp = MockComponent('fooHub', 0) comp.addOutput('conn') compList.append(comp) comp = MockComponent('bar', 0) comp.addInput('conn', 123) compList.append(comp) comp = MockComponent('baz', 0) comp.addInput('conn', 456) compList.append(comp) self.assertEqual(len(mgr.pool), 0) nameList = [] for c in compList: mgr.add(c) nameList.append(c.name) self.assertEqual(len(mgr.pool), len(compList)) logger = MockLogger('main') runset = mgr.makeRunset(nameList, logger) self.assertEqual(len(mgr.pool), 0) found = mgr.findRunset(runset.id) self.failIf(found is None, "Couldn't find runset #" + str(runset.id)) mgr.returnRunset(runset) self.assertEqual(len(mgr.pool), len(compList)) for c in compList: mgr.remove(c) self.assertEqual(len(mgr.pool), 0) logger.checkStatus(10)