From d71c76b1496ca58a7cef4e644b357f9b937775f5 Mon Sep 17 00:00:00 2001 From: Cintu07 <178455858+Cintu07@users.noreply.github.com> Date: Sat, 8 Aug 2026 00:46:56 +0530 Subject: [PATCH] test(pipecat): assert _store_messages calls client.add, not memories.add --- .../tests/test_empty_profile.py | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/pipecat-sdk-python/tests/test_empty_profile.py b/packages/pipecat-sdk-python/tests/test_empty_profile.py index ec3ccd26..1b3fc63c 100644 --- a/packages/pipecat-sdk-python/tests/test_empty_profile.py +++ b/packages/pipecat-sdk-python/tests/test_empty_profile.py @@ -120,4 +120,30 @@ class TestSupermemoryPipecatNullProfile(unittest.IsolatedAsyncioTestCase): "profile": {"static": [], "dynamic": []}, "search_results": [], }, - ) \ No newline at end of file + ) + + +class _MockAddClient: + """a client that only exposes the top-level add, not memories.add.""" + + def __init__(self): + self.add = AsyncMock(return_value=SimpleNamespace(id="doc_123")) + + +class TestSupermemoryPipecatStoreMessages(unittest.IsolatedAsyncioTestCase): + async def test_store_messages_calls_top_level_add(self) -> None: + # regression guard: supermemory 3.x moved add off client.memories to the + # top level. _store_messages must call client.add, not client.memories.add. + # the mock has no memories attribute, so a reverted call would raise, + # get swallowed by the fire-and-forget block, and add would never fire. + service = SupermemoryPipecatService(api_key="mock_key", user_id="user_123") + client = _MockAddClient() + service._supermemory_client = client + + await service._store_messages([{"role": "user", "content": "hello"}]) + + client.add.assert_awaited_once() + _, kwargs = client.add.await_args + self.assertIn("content", kwargs) + self.assertEqual(kwargs["container_tags"], ["user_123"]) + self.assertFalse(hasattr(client, "memories")) \ No newline at end of file