feat: enhance chat CLI and TUI with initial opener handling and improved prompt logic
This commit is contained in:
@@ -162,13 +162,18 @@ class TestAsyncFastGPTClientSendRequest:
|
||||
mock_response = Mock(spec=httpx.Response)
|
||||
mock_response.status_code = 200
|
||||
|
||||
# Track if close was called on the response
|
||||
original_close_called = []
|
||||
original_sync_close_called = []
|
||||
original_async_close_called = []
|
||||
|
||||
async def original_close():
|
||||
original_close_called.append(True)
|
||||
def original_close():
|
||||
original_sync_close_called.append(True)
|
||||
raise AssertionError("sync close should not be used for async streaming responses")
|
||||
|
||||
mock_response.close = original_close
|
||||
async def original_aclose():
|
||||
original_async_close_called.append(True)
|
||||
|
||||
mock_response.close = Mock(side_effect=original_close)
|
||||
mock_response.aclose = AsyncMock(side_effect=original_aclose)
|
||||
|
||||
mock_stream_context = AsyncContextManagerMock(mock_response)
|
||||
|
||||
@@ -182,8 +187,9 @@ class TestAsyncFastGPTClientSendRequest:
|
||||
|
||||
# Verify stream context exit was called
|
||||
mock_stream_context.__aexit__.assert_called_once_with(None, None, None)
|
||||
# Verify the original close was called
|
||||
assert len(original_close_called) == 1
|
||||
# Verify async cleanup path was used instead of sync close()
|
||||
assert len(original_sync_close_called) == 0
|
||||
assert len(original_async_close_called) == 1
|
||||
await client.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user