def testAddEvent(self): f = Mock() manager = secsgem.HsmsConnectionManager() manager.events.test += f self.assertIn("test", manager.events)
def testAddActivePeer(self): server = HsmsTestServer() manager = secsgem.HsmsConnectionManager() manager._testServerObject = server manager.add_peer("test", "127.0.0.1", 1234, True, 0) self.assertIsNotNone(manager.has_connection_to("test")) manager.stop()
def testHasConnectionToUnknownHost(self): manager = secsgem.HsmsConnectionManager() self.assertIsNone(manager.has_connection_to("test")) self.assertIsNone(manager["test"])
def testConstructor(self): manager = secsgem.HsmsConnectionManager() self.assertIsNotNone(manager)
eventNotify[queue].clear() result = list(events[queue]) events[queue] = [] eventsLock.release() return result # setup event handler eventHandler = secsgem.EventHandler(events={'handler_communicating': ceSetup}, generic_handler=_onEvent) # setup connection manager connectionManager = secsgem.HsmsConnectionManager(event_handler=eventHandler) def addTool(tool): # skip disabled tools if not tool.enabled: return toolType = getToolType(tool) # add configured tool to the connectionmanager handler = connectionManager.add_peer(tool.name, tool.address, tool.port, tool.passive, tool.device_id, toolType) ceids = []