mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-04-25 19:28:23 +00:00
- Fix naive datetime.now() → datetime.now(UTC) in all ORM models - Fix seq race condition in DbRunEventStore.put() with FOR UPDATE and UNIQUE(thread_id, seq) constraint - Encapsulate _store access in RunManager.update_run_completion() - Deduplicate _store.put() logic in RunManager via _persist_to_store() - Add update_run_completion to RunStore ABC + MemoryRunStore - Wire follow_up_to_run_id through the full create path - Add error recovery to RunJournal._flush_sync() lost-event scenario - Add migration note for search_threads breaking change - Fix test_checkpointer_none_fix mock to set database=None Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
56 lines
2.5 KiB
Python
56 lines
2.5 KiB
Python
"""Test for issue #1016: checkpointer should not return None."""
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
from langgraph.checkpoint.memory import InMemorySaver
|
|
|
|
|
|
class TestCheckpointerNoneFix:
|
|
"""Tests that checkpointer context managers return InMemorySaver instead of None."""
|
|
|
|
@pytest.mark.anyio
|
|
async def test_async_make_checkpointer_returns_in_memory_saver_when_not_configured(self):
|
|
"""make_checkpointer should return InMemorySaver when config.checkpointer is None."""
|
|
from deerflow.agents.checkpointer.async_provider import make_checkpointer
|
|
|
|
# Mock get_app_config to return a config with checkpointer=None and database=None
|
|
mock_config = MagicMock()
|
|
mock_config.checkpointer = None
|
|
mock_config.database = None
|
|
|
|
with patch("deerflow.agents.checkpointer.async_provider.get_app_config", return_value=mock_config):
|
|
async with make_checkpointer() as checkpointer:
|
|
# Should return InMemorySaver, not None
|
|
assert checkpointer is not None
|
|
assert isinstance(checkpointer, InMemorySaver)
|
|
|
|
# Should be able to call alist() without AttributeError
|
|
# This is what LangGraph does and what was failing in issue #1016
|
|
result = []
|
|
async for item in checkpointer.alist(config={"configurable": {"thread_id": "test"}}):
|
|
result.append(item)
|
|
|
|
# Empty list is expected for a fresh checkpointer
|
|
assert result == []
|
|
|
|
def test_sync_checkpointer_context_returns_in_memory_saver_when_not_configured(self):
|
|
"""checkpointer_context should return InMemorySaver when config.checkpointer is None."""
|
|
from deerflow.agents.checkpointer.provider import checkpointer_context
|
|
|
|
# Mock get_app_config to return a config with checkpointer=None
|
|
mock_config = MagicMock()
|
|
mock_config.checkpointer = None
|
|
|
|
with patch("deerflow.agents.checkpointer.provider.get_app_config", return_value=mock_config):
|
|
with checkpointer_context() as checkpointer:
|
|
# Should return InMemorySaver, not None
|
|
assert checkpointer is not None
|
|
assert isinstance(checkpointer, InMemorySaver)
|
|
|
|
# Should be able to call list() without AttributeError
|
|
result = list(checkpointer.list(config={"configurable": {"thread_id": "test"}}))
|
|
|
|
# Empty list is expected for a fresh checkpointer
|
|
assert result == []
|