import asyncio import sys import os # Add the project root to sys.path sys.path.append(os.getcwd()) from app.database.memory_db import db_memory_store async def verify_clear(): # This test requires a database connection, but we can test the cache part conv_id = "test_sync_id" # Manually inject into cache db_memory_store._cache[conv_id] = {"id": conv_id, "history": ["test"]} print(f"Cache before clear: {conv_id in db_memory_store._cache}") # Clear (will try DB too, might fail if no DB but cache should be cleared) try: await db_memory_store.clear(conv_id) except Exception as e: print(f"DB part failed as expected (no connection probably): {e}") print(f"Cache after clear: {conv_id in db_memory_store._cache}") if conv_id not in db_memory_store._cache: print("✅ Cache sync test passed!") else: print("❌ Cache sync test failed!") if __name__ == "__main__": asyncio.run(verify_clear())