@@ -42,6 +42,31 @@ def readinto(self, b: bytearray) -> int:
4242 return n
4343
4444
45+ def _make_execution (ipc_bytes : bytes ):
46+ """Return an Execution backed by a mock API client."""
47+ from gooddata_sdk .compute .model .execution import Execution
48+
49+ mock_api_client = MagicMock ()
50+ mock_response = _FakeResponse (ipc_bytes )
51+ mock_api_client .actions_api .api_client .call_api .return_value = mock_response
52+
53+ afm_exec_response = {
54+ "execution_response" : {
55+ "links" : {"executionResult" : "result-id-123" },
56+ "dimensions" : [],
57+ }
58+ }
59+ mock_exec_def = MagicMock ()
60+
61+ execution = Execution (
62+ api_client = mock_api_client ,
63+ workspace_id = "ws-id" ,
64+ exec_def = mock_exec_def ,
65+ response = afm_exec_response ,
66+ )
67+ return execution , mock_response
68+
69+
4570def _make_bare (ipc_bytes : bytes ):
4671 """Return a BareExecutionResponse backed by a mock API client."""
4772 from gooddata_sdk .compute .model .execution import BareExecutionResponse
@@ -108,3 +133,33 @@ def test_read_result_arrow_no_pyarrow_raises() -> None:
108133
109134 with patch .object (_exec_mod , "_ipc" , None ), pytest .raises (ImportError , match = "pyarrow is required" ):
110135 bare .read_result_arrow ()
136+
137+
138+ # ---------------------------------------------------------------------------
139+ # Execution.read_result_arrow – delegates to BareExecutionResponse
140+ # ---------------------------------------------------------------------------
141+
142+
143+ def test_execution_read_result_arrow_returns_table () -> None :
144+ """Execution.read_result_arrow() delegates to BareExecutionResponse and returns a pa.Table."""
145+ import pyarrow as pa
146+
147+ ipc_bytes = _make_ipc_stream_bytes ()
148+ execution , mock_response = _make_execution (ipc_bytes )
149+
150+ result = execution .read_result_arrow ()
151+
152+ assert isinstance (result , pa .Table )
153+ mock_response .release_conn .assert_called_once ()
154+
155+
156+ def test_execution_read_result_arrow_calls_binary_endpoint () -> None :
157+ """Execution.read_result_arrow() hits the /binary endpoint with the correct Accept header."""
158+ ipc_bytes = _make_ipc_stream_bytes ()
159+ execution , _ = _make_execution (ipc_bytes )
160+
161+ execution .read_result_arrow ()
162+
163+ call_kwargs = execution .bare_exec_response ._actions_api .api_client .call_api .call_args .kwargs
164+ assert call_kwargs ["header_params" ]["Accept" ] == "application/vnd.apache.arrow.stream"
165+ assert "/binary" in call_kwargs ["resource_path" ]
0 commit comments