Exemplo n.º 1
0
def test_context_manager_enter_calls_ffi_api():
    h = Hermes(HOST)
    h.ffi = mock.MagicMock()

    h.__enter__()
    h.__exit__(None, None, None)

    h.ffi.establish_connection.assert_called_once()
    h.ffi.release_connection.assert_called_once()
Exemplo n.º 2
0
def test_subscribe_intent_correctly_registers_callback():
    def user_callback(hermes, intentMessage):
        pass

    h = Hermes(HOST)
    h.ffi = mock.MagicMock()
    h.__enter__()
    h.subscribe_intent(DUMMY_INTENT_NAME, user_callback)
    h.__exit__(None, None, None)
    h.ffi.dialogue.register_subscribe_intent_handler.assert_called_once_with(
        DUMMY_INTENT_NAME, user_callback, h)
Exemplo n.º 3
0
def test_subscribe_intents_correctly_registers_callback():
    def user_callback(hermes, intentMessage):
        pass

    h = Hermes(HOST)
    h.ffi = mock.MagicMock()
    h.__enter__()
    h.subscribe_intents(user_callback)
    h.__exit__(None, None, None)

    h.ffi.establish_connection.assert_called_once()
    h.ffi.dialogue.register_subscribe_intents_handler.assert_called_once_with(
        user_callback, h)