mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 00:16:57 +08:00
test: inject agent protocol config snapshots
This commit is contained in:
@@ -8,7 +8,6 @@ from fastapi.security import HTTPAuthorizationCredentials
|
|||||||
|
|
||||||
from app import schemas
|
from app import schemas
|
||||||
from app.api.endpoints import anthropic, openai
|
from app.api.endpoints import anthropic, openai
|
||||||
from app.runtime.config import settings
|
|
||||||
|
|
||||||
_API_TOKEN = "test-agent-protocol-token"
|
_API_TOKEN = "test-agent-protocol-token"
|
||||||
|
|
||||||
@@ -73,10 +72,18 @@ def test_streaming_protocols_reject_config_disable_before_manager_lookup() -> No
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch.object(settings, "AI_AGENT_ENABLE", False), patch.object(
|
runtime_config = SimpleNamespace(
|
||||||
settings,
|
ai_agent_enable=False,
|
||||||
"API_TOKEN",
|
api_token=_API_TOKEN,
|
||||||
_API_TOKEN,
|
)
|
||||||
|
with patch.object(
|
||||||
|
openai,
|
||||||
|
"get_api_runtime_config_snapshot",
|
||||||
|
return_value=runtime_config,
|
||||||
|
), patch.object(
|
||||||
|
anthropic,
|
||||||
|
"get_api_runtime_config_snapshot",
|
||||||
|
return_value=runtime_config,
|
||||||
), patch.object(
|
), patch.object(
|
||||||
openai,
|
openai,
|
||||||
"get_running_agent_manager",
|
"get_running_agent_manager",
|
||||||
@@ -111,10 +118,13 @@ def test_openai_stream_rejects_shutdown_race_and_cleans_request_session() -> Non
|
|||||||
)
|
)
|
||||||
return await _collect(response)
|
return await _collect(response)
|
||||||
|
|
||||||
with patch.object(settings, "AI_AGENT_ENABLE", True), patch.object(
|
with patch.object(
|
||||||
settings,
|
openai,
|
||||||
"API_TOKEN",
|
"get_api_runtime_config_snapshot",
|
||||||
_API_TOKEN,
|
return_value=SimpleNamespace(
|
||||||
|
ai_agent_enable=True,
|
||||||
|
api_token=_API_TOKEN,
|
||||||
|
),
|
||||||
), patch.object(
|
), patch.object(
|
||||||
openai,
|
openai,
|
||||||
"get_running_agent_manager",
|
"get_running_agent_manager",
|
||||||
@@ -145,10 +155,13 @@ def test_anthropic_stream_rejects_shutdown_race_and_cleans_request_session() ->
|
|||||||
)
|
)
|
||||||
return await _collect(response)
|
return await _collect(response)
|
||||||
|
|
||||||
with patch.object(settings, "AI_AGENT_ENABLE", True), patch.object(
|
with patch.object(
|
||||||
settings,
|
anthropic,
|
||||||
"API_TOKEN",
|
"get_api_runtime_config_snapshot",
|
||||||
_API_TOKEN,
|
return_value=SimpleNamespace(
|
||||||
|
ai_agent_enable=True,
|
||||||
|
api_token=_API_TOKEN,
|
||||||
|
),
|
||||||
), patch.object(
|
), patch.object(
|
||||||
anthropic,
|
anthropic,
|
||||||
"get_running_agent_manager",
|
"get_running_agent_manager",
|
||||||
|
|||||||
Reference in New Issue
Block a user