mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-08-04 20:08:40 +00:00
fix(tests): isolate custom agent test from local config.yaml (#4645)
This commit is contained in:
parent
91d7f4e4fa
commit
8659fca8fd
@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from types import SimpleNamespace
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -513,6 +514,20 @@ class TestMemoryFilePath:
|
|||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
|
|
||||||
|
|
||||||
|
# Model names the agents API tests may send in a create/update payload. The
|
||||||
|
# router validates `model` against the app config, so the fixture pins a stub
|
||||||
|
# config exposing exactly these instead of leaving the assertion at the mercy
|
||||||
|
# of whatever `config.yaml` happens to sit in the repo root: CI has none (the
|
||||||
|
# validation is skipped and the request passes), a real dev checkout does (an
|
||||||
|
# unlisted model name yields 422 and the test fails).
|
||||||
|
_KNOWN_TEST_MODELS = frozenset({"deepseek-v3"})
|
||||||
|
|
||||||
|
|
||||||
|
def _stub_app_config():
|
||||||
|
"""App config that knows only ``_KNOWN_TEST_MODELS``."""
|
||||||
|
return SimpleNamespace(get_model_config=lambda name: SimpleNamespace(name=name) if name in _KNOWN_TEST_MODELS else None)
|
||||||
|
|
||||||
|
|
||||||
def _make_test_app(tmp_path: Path):
|
def _make_test_app(tmp_path: Path):
|
||||||
"""Create a FastAPI app with the agents router, patching paths to tmp_path."""
|
"""Create a FastAPI app with the agents router, patching paths to tmp_path."""
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
@ -532,7 +547,11 @@ def agent_client(tmp_path):
|
|||||||
paths_instance = _make_paths(tmp_path)
|
paths_instance = _make_paths(tmp_path)
|
||||||
previous_config = AgentsApiConfig(**get_agents_api_config().model_dump())
|
previous_config = AgentsApiConfig(**get_agents_api_config().model_dump())
|
||||||
|
|
||||||
with patch("deerflow.config.agents_config.get_paths", return_value=paths_instance), patch.object(agents_router, "get_paths", return_value=paths_instance):
|
with (
|
||||||
|
patch("deerflow.config.agents_config.get_paths", return_value=paths_instance),
|
||||||
|
patch.object(agents_router, "get_paths", return_value=paths_instance),
|
||||||
|
patch.object(agents_router, "get_app_config", _stub_app_config),
|
||||||
|
):
|
||||||
set_agents_api_config(AgentsApiConfig(enabled=True))
|
set_agents_api_config(AgentsApiConfig(enabled=True))
|
||||||
try:
|
try:
|
||||||
app = _make_test_app(tmp_path)
|
app = _make_test_app(tmp_path)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user