Ejemplo n.º 1
0
async def test_handler_unregister(mocker):
    cb = mocker.MagicMock()

    h_name = "removable"
    handler = PersistentHandler(cb, name=h_name)

    mm = AsyncMessageManager()
    mm.register_handler(handler)

    assert len(mm.handler_registry) == 1

    mm.deregister_handler(h_name)

    assert len(mm.handler_registry) == 0
Ejemplo n.º 2
0
async def test_raw_handler_register_unregister(mocker):
    cb = mocker.MagicMock()
    msg = Container()

    h_name = 'removable'
    handler = RAWMessageHandler(cb, name=h_name)

    mm = AsyncMessageManager()
    mm.register_handler(handler)

    assert len(mm.raw_handlers) == 1

    mm.deregister_handler(h_name)

    assert len(mm.raw_handlers) == 0