本文整理汇总了Python中agentzero.core.SocketManager.registry方法的典型用法代码示例。如果您正苦于以下问题:Python SocketManager.registry方法的具体用法?Python SocketManager.registry怎么用?Python SocketManager.registry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类agentzero.core.SocketManager
的用法示例。
在下文中一共展示了SocketManager.registry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_socket_manager_register_socket
# 需要导入模块: from agentzero.core import SocketManager [as 别名]
# 或者: from agentzero.core.SocketManager import registry [as 别名]
def test_socket_manager_register_socket():
(
"SocketManager().register_socket() should register "
"a socket only once even if called twice"
)
# Given a zmq mock
zmq = Mock()
# And a context
context = Mock()
# And a socket manager with a fake socket in the pool
manager = SocketManager(zmq, context)
manager.registry = {}
# When I call register_socket
result = manager.register_socket("fake-socket", "fake-polling-mechanism")
# Then it should return the socket itself
result.should.equal("fake-socket")
# And it should have been registered with the poller
manager.poller.register.assert_called_once_with(
"fake-socket", "fake-polling-mechanism"
)
# And it should have been added to the internal registry
manager.registry.should.have.key("fake-socket").being.equal(
"fake-polling-mechanism"
)