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

Function test_builtin_with_default_port

tests/stream/test_main.py:200–225  ·  view source on GitHub ↗

Test scenario: builtin() function uses default port when port=None Expected: Cover line 110 (if port is None: port = 3120)

()

Source from the content-addressed store, hash-verified

198
199@pytest.mark.asyncio
200async def test_builtin_with_default_port():
201 """
202 Test scenario: builtin() function uses default port when port=None
203 Expected: Cover line 110 (if port is None: port = 3120)
204 """
205 with (
206 patch("stream.main.ProxyServer") as mock_proxy_class,
207 patch("stream.main.logging.getLogger") as mock_get_logger,
208 ):
209 mock_logger = MagicMock()
210 mock_get_logger.return_value = mock_logger
211
212 # Mock ProxyServer to immediately raise KeyboardInterrupt
213 mock_proxy = AsyncMock()
214 mock_proxy.start = AsyncMock(side_effect=KeyboardInterrupt)
215 mock_proxy_class.return_value = mock_proxy
216
217 from stream.main import builtin
218
219 # Call builtin with port=None (line 110 should execute)
220 await builtin(queue=None, port=None, proxy=None)
221
222 # Verify ProxyServer was created with default port 3120
223 mock_proxy_class.assert_called_once()
224 call_kwargs = mock_proxy_class.call_args[1]
225 assert call_kwargs["port"] == 3120 # Default port was used
226
227
228@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 1

builtinFunction · 0.90

Tested by

no test coverage detected