Restructure backend and frontend modules; add story, library, and editor schema migrations. Support editable automatic production, manual confirmation modes, account and user lifecycle management, compact container scrolling, consistent forms, and per-task result previews. Update inference and TTS scheduling, deployment guidance, and regression coverage; remove obsolete standalone pages and temporary acceptance artifacts.
42 lines
1.7 KiB
Python
42 lines
1.7 KiB
Python
import asyncio
|
|
from types import SimpleNamespace
|
|
|
|
import httpx
|
|
import pytest
|
|
|
|
from app.adapters.provider.client import Provider
|
|
from app.domain.errors import MediaError
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_qwen_cold_load_uses_independent_transport_and_total_timeout():
|
|
seen = []
|
|
async def upstream(request):
|
|
seen.append(request.extensions['timeout']['read'])
|
|
await asyncio.sleep(1.08)
|
|
return httpx.Response(200, json={'choices': [{'message': {'content': '2'}}]})
|
|
settings = SimpleNamespace(request_timeout_seconds=.01, qwen_timeout_seconds=2,
|
|
qwen_base_url='http://qwen.test/v1', qwen_model='example', qwen_api_key='')
|
|
provider = Provider(settings)
|
|
await provider.client.aclose()
|
|
provider.client = httpx.AsyncClient(transport=httpx.MockTransport(upstream), timeout=.01)
|
|
try:
|
|
assert await provider._chat([{'role':'user', 'content':'1+1'}]) == '2'
|
|
assert seen == [2], 'Qwen must override the HTTP read timeout as well as the total deadline'
|
|
with pytest.raises(MediaError, match='超时'):
|
|
await provider._json('GET', 'http://qwen.test/slow-control')
|
|
finally:
|
|
await provider.aclose()
|
|
|
|
|
|
def test_qwen_timeout_config_is_separate_from_normal_api_timeout(monkeypatch):
|
|
from app.core.config import Settings
|
|
monkeypatch.setenv('CMVR_MODE', 'test')
|
|
monkeypatch.setenv('DATABASE_URL', 'sqlite+aiosqlite:///:memory:')
|
|
assert hasattr(Settings.from_env(), 'qwen_timeout_seconds'), 'Qwen cold startup needs its own configured wait'
|
|
monkeypatch.setenv('QWEN_TIMEOUT_SECONDS', '600')
|
|
monkeypatch.setenv('REQUEST_TIMEOUT_SECONDS', '3')
|
|
settings = Settings.from_env()
|
|
assert settings.qwen_timeout_seconds == 600
|
|
assert settings.request_timeout_seconds == 3
|