Пример #1
0
    def testAddEvent(self):
        f = Mock()

        manager = secsgem.HsmsConnectionManager()

        manager.events.test += f

        self.assertIn("test", manager.events)
Пример #2
0
    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()
Пример #3
0
 def testHasConnectionToUnknownHost(self):
     manager = secsgem.HsmsConnectionManager()
     self.assertIsNone(manager.has_connection_to("test"))
     self.assertIsNone(manager["test"])
Пример #4
0
    def testConstructor(self):
        manager = secsgem.HsmsConnectionManager()

        self.assertIsNotNone(manager)
Пример #5
0
        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 = []