def test_queue(): r"""Test creation/removal of queue.""" mq = IPCComm.get_queue() key = str(mq.key) assert (CommBase.is_registered('ipc', key)) IPCComm.IPCComm.unregister_comm(key, dont_close=True) assert_raises(KeyError, IPCComm.remove_queue, mq) IPCComm.IPCComm.register_comm(key, mq) IPCComm.remove_queue(mq) assert (not CommBase.is_registered('ipc', key))
def test_registry(): r"""Test registry of comm.""" comm_class = 'CommBase' key = 'key1' value = None assert (not CommBase.is_registered(comm_class, key)) assert (not CommBase.unregister_comm(comm_class, key)) assert_equal(CommBase.get_comm_registry(None), {}) assert_equal(CommBase.get_comm_registry(comm_class), {}) CommBase.register_comm(comm_class, key, value) assert (key in CommBase.get_comm_registry(comm_class)) assert (CommBase.is_registered(comm_class, key)) assert (not CommBase.unregister_comm(comm_class, key, dont_close=True)) CommBase.register_comm(comm_class, key, value) assert (not CommBase.unregister_comm(comm_class, key))
def test_registry(): r"""Test registry of comm.""" from yggdrasil.communication import CommBase comm_class = 'CommBase' key = 'key1' value = None assert (not CommBase.is_registered(comm_class, key)) assert (not CommBase.unregister_comm(comm_class, key)) assert (CommBase.get_comm_registry(None) == {}) assert (CommBase.get_comm_registry(comm_class) == {}) CommBase.register_comm(comm_class, key, value) assert (key in CommBase.get_comm_registry(comm_class)) assert (CommBase.is_registered(comm_class, key)) assert (not CommBase.unregister_comm(comm_class, key, dont_close=True)) CommBase.register_comm(comm_class, key, value) assert (not CommBase.unregister_comm(comm_class, key))
def remove_queue(mq): r"""Remove a sysv_ipc.MessageQueue and unregister it. Args: mq (:class:`sysv_ipc.MessageQueue`) Message queue. Raises: KeyError: If the provided queue is not registered. """ key = str(mq.key) if not CommBase.is_registered('IPCComm', key): raise KeyError("Queue not registered.") CommBase.unregister_comm('IPCComm', key)