mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-04-25 11:18:22 +00:00
Tail-end of Phase 2: - Migrate ~70 remaining test sites off AppConfig.current(): drop dead monkey-patches (production no longer calls current), hoist the mocked config into a local variable and pass it explicitly. Verified with `grep -rn 'AppConfig\.current' backend/tests` → empty. - Delete the AppConfig.current() classmethod entirely. The transitional raise-only shim is no longer needed now that no test references it. - Update docs: plan marked shipped (P2-6..P2-10 in commit 84dccef2); backend/CLAUDE.md Config Lifecycle rewritten to describe the explicit-parameter design; gateway/deps.py docstrings no longer point at the removed current() surface. AppConfig is now a pure Pydantic value object. Every consumer holds its own captured instance — Gateway (app.state.config via Depends(get_config)), DeerFlowClient (self._app_config), agent runtime (DeerFlowContext.app_config), LangGraph Server bootstrap (AppConfig.from_file() inside make_lead_agent). 2337 non-e2e tests pass.
52 lines
2.1 KiB
Python
52 lines
2.1 KiB
Python
"""Test for issue #1016: checkpointer should not return None."""
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
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.runtime.checkpointer.async_provider import make_checkpointer
|
|
|
|
mock_config = MagicMock()
|
|
mock_config.checkpointer = None
|
|
mock_config.database = None
|
|
|
|
async with make_checkpointer(mock_config) 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.runtime.checkpointer.provider import checkpointer_context
|
|
|
|
mock_config = MagicMock()
|
|
mock_config.checkpointer = None
|
|
|
|
with checkpointer_context(mock_config) 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 == []
|