async def test_chat_stream(self):
        """Ensures that chat method calls _stream when stream=True."""
        messages = [{"role": "user", "content": "Hello"}]
        response_mock = MagicMock()
        response_mock.status_code = 200
        response_mock.raise_for_status = Mock()
        response_mock.aiter_lines.return_value = self.async_iter(
            ['data: {"key": "value"}', "[DONE]"]
        )

        @asynccontextmanager
        async def stream_context_manager(*args, **kwargs):
            yield response_mock

        self.client._client.stream = Mock(side_effect=stream_context_manager)

        result = []
        async for item in await self.client.chat(messages=messages, stream=True):
            result.append(item)

        assert result == [{"key": "value"}]
Ensures that chat method calls _stream when stream=True.
llama-index-integrations/llms/llama-index-llms-oci-data-science/tests/test_oci_data_science_client.py