From b17f733df2c9d5fca6b8128d4f47e52df62ab3ec Mon Sep 17 00:00:00 2001 From: Piero Savastano Date: Fri, 1 Nov 2024 21:09:53 +0100 Subject: [PATCH] update fast_reply hook tests --- core/tests/looking_glass/test_stray_cat.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/tests/looking_glass/test_stray_cat.py b/core/tests/looking_glass/test_stray_cat.py index c54f22453..ab5db50f7 100644 --- a/core/tests/looking_glass/test_stray_cat.py +++ b/core/tests/looking_glass/test_stray_cat.py @@ -67,6 +67,7 @@ def test_recall_to_working_memory(stray): assert stray.working_memory.episodic_memories[0][0].page_content == msg_text +# TODO: should we gather all tests regarding hooks in a folder? def test_stray_fast_reply_hook(stray): user_msg = "hello" fast_reply_msg = "This is a fast reply" @@ -83,11 +84,13 @@ def fast_reply_hook(fast_reply: dict, cat): msg = {"text": user_msg, "user_id": "Alice"} # send message - stray.loop.run_until_complete(stray.__call__(msg)) - # used to check if the user message was stored in episodic memory - stray.recall_relevant_memories_to_working_memory(user_msg) + res = stray.__call__(msg) + + assert isinstance(res, CatMessage) + assert res.content == fast_reply_msg + # there should be NO side effects assert stray.working_memory.user_message_json.text == user_msg - assert stray.working_memory.history[-2]["message"] == user_msg - assert stray.working_memory.history[-1]["message"] == fast_reply_msg - assert len(stray.working_memory.episodic_memories) == 1 + assert len(stray.working_memory.history) == 0 + stray.recall_relevant_memories_to_working_memory(user_msg) + assert len(stray.working_memory.episodic_memories) == 0