Stabilize backend tests without local config

This commit is contained in:
taohe
2026-06-11 18:07:06 +08:00
parent b8323024c9
commit 6956b247fd
2 changed files with 23 additions and 1 deletions
@@ -5,15 +5,25 @@ from __future__ import annotations
from types import SimpleNamespace from types import SimpleNamespace
from uuid import UUID from uuid import UUID
import pytest
from _router_auth_helpers import make_authed_test_app from _router_auth_helpers import make_authed_test_app
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from app.channels.runtime_config_store import ChannelRuntimeConfigStore from app.channels.runtime_config_store import ChannelRuntimeConfigStore
from app.gateway.auth.models import User from app.gateway.auth.models import User
from app.gateway.routers import channel_connections from app.gateway.routers import channel_connections
from deerflow.config.app_config import AppConfig, reset_app_config, set_app_config
from deerflow.config.channel_connections_config import ChannelConnectionsConfig from deerflow.config.channel_connections_config import ChannelConnectionsConfig
@pytest.fixture(autouse=True)
def _stub_app_config():
"""Keep router tests independent from a developer-local config.yaml."""
set_app_config(AppConfig.model_validate({"sandbox": {"use": "deerflow.sandbox.local:LocalSandboxProvider"}}))
yield
reset_app_config()
def _user() -> User: def _user() -> User:
return User( return User(
id=UUID("11111111-2222-3333-4444-555555555555"), id=UUID("11111111-2222-3333-4444-555555555555"),
+13 -1
View File
@@ -4,6 +4,18 @@ from __future__ import annotations
import json import json
import pytest
from deerflow.config.app_config import AppConfig, reset_app_config, set_app_config
@pytest.fixture
def _stub_app_config():
"""Keep run-context tests independent from a developer-local config.yaml."""
set_app_config(AppConfig.model_validate({"sandbox": {"use": "deerflow.sandbox.local:LocalSandboxProvider"}}))
yield
reset_app_config()
def test_format_sse_basic(): def test_format_sse_basic():
from app.gateway.services import format_sse from app.gateway.services import format_sse
@@ -474,7 +486,7 @@ def test_inject_authenticated_user_context_skips_internal_role():
assert config["context"]["user_id"] == "channel-user-7" assert config["context"]["user_id"] == "channel-user-7"
def test_start_run_uses_internal_owner_header_for_persistence(): def test_start_run_uses_internal_owner_header_for_persistence(_stub_app_config):
import asyncio import asyncio
from types import SimpleNamespace from types import SimpleNamespace
from unittest.mock import patch from unittest.mock import patch