MCPcopy Create free account
hub / github.com/CJackHwang/AIstudioProxyAPI / test_start_stream_proxy_success

Function test_start_stream_proxy_success

tests/api_utils/test_app.py:310–338  ·  view source on GitHub ↗

Test _start_stream_proxy success path.

()

Source from the content-addressed store, hash-verified

308
309@pytest.mark.asyncio
310async def test_start_stream_proxy_success():
311 """Test _start_stream_proxy success path."""
312 state.STREAM_QUEUE = None
313 state.STREAM_PROCESS = None
314
315 with (
316 patch("api_utils.app.get_environment_variable") as mock_get_env,
317 patch("multiprocessing.Queue") as mock_queue_cls,
318 patch("multiprocessing.Process") as mock_process_cls,
319 ):
320 mock_get_env.side_effect = lambda key, default=None: {
321 "STREAM_PORT": "3120",
322 "UNIFIED_PROXY_CONFIG": "http://upstream:8080",
323 }.get(key, default)
324
325 mock_queue = MagicMock()
326 mock_queue.get.return_value = "READY"
327 mock_queue_cls.return_value = mock_queue
328
329 mock_process = MagicMock()
330 mock_process_cls.return_value = mock_process
331
332 await _start_stream_proxy()
333
334 assert state.STREAM_QUEUE is not None
335 assert state.STREAM_PROCESS is not None
336 mock_process.start.assert_called_once()
337 # Verify queue.get was called (via asyncio.to_thread, so we check the mock)
338 mock_queue.get.assert_called()
339
340
341@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 2

_start_stream_proxyFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected