Spaces:
Sleeping

studiq-backend / tests /test_memory_compaction.py
StudIQ Deploy Bot
Deploy from GitHub 336c411cba6a5f729ebdd4dba12a182faa91f51c
d6167ae
Raw History Blame Contribute Delete
549 Bytes
"""Unit tests for conversation turn grouping in daily memory compaction."""
import pytest
def test_message_grouping_by_user():
"""Verify grouping raw messages by user ID for batch compaction."""
messages = [
{"user_id": "u1", "content": "Topic 1"},
{"user_id": "u2", "content": "Topic 2"},
{"user_id": "u1", "content": "Topic 3"},
]
grouped = {}
for m in messages:
grouped.setdefault(m["user_id"], []).append(m["content"])
assert len(grouped["u1"]) == 2
assert len(grouped["u2"]) == 1