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()
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)
def test_start_session_notification_2(): h = Hermes(HOST) h.ffi = mock.MagicMock() with h: h.publish_start_session_notification(None, None, "custom_data", "yup!") start_session_notification_message = StartSessionMessage( SessionInitNotification("yup!"), "custom_data", None) h.ffi.dialogue.publish_start_session.assert_called_once_with( start_session_notification_message)
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)
def test_start_session_notification_text_parameter_takes_precedence_over_session_initiation_text( ): h = Hermes(HOST) h.ffi = mock.MagicMock() with h: h.publish_start_session_notification(None, "test", "custom_data", "yup!") start_session_notification_message = StartSessionMessage( SessionInitNotification("yup!"), "custom_data", None) h.ffi.dialogue.publish_start_session.assert_called_once_with( start_session_notification_message)
def test_continue_session_slot_filler(self): h = Hermes(HOST) h.ffi = mock.MagicMock() with h: h.publish_continue_session("session_id", "Tell me what the missing slot is", ["intent1"], None, False, "missing_slot") continue_session_message = ContinueSessionMessage( "session_id", "Tell me what the missing slot is", ["intent1"], None, False, "missing_slot") h.ffi.dialogue.publish_continue_session.assert_called_once_with( continue_session_message)