def test_ttl_configuration(mongo_container):
    """Test TTL configuration is applied correctly."""
    # Create chat store with TTL
    chat_store = MongoChatStore(
        mongo_uri=mongo_container["mongodb_uri"],
        db_name="test_ttl_db",
        collection_name="test_ttl_chats",
        ttl_seconds=3600,  # 1 hour TTL
    )

    # Verify TTL index was created
    indexes = list(chat_store._collection.list_indexes())
    ttl_index = next((idx for idx in indexes if "created_at" in idx["key"]), None)

    assert ttl_index is not None
    assert ttl_index.get("expireAfterSeconds") == 3600

    # Clean up
    chat_store._collection.drop()
Test TTL configuration is applied correctly.
llama-index-integrations/storage/chat_store/llama-index-storage-chat-store-mongo/tests/test_chat_store_mongo_chat_store.py