@@ -27,38 +27,6 @@ def mock_sea_client(self):
2727"""Create a mock SEA client."""
2828return Mock ()
2929
30- @pytest .fixture
31- def sea_response (self ):
32- """Create a sample SEA response."""
33- return {
34- "statement_id" :"test-statement-123" ,
35- "status" : {"state" :"SUCCEEDED" },
36- "manifest" : {
37- "format" :"JSON_ARRAY" ,
38- "schema" : {
39- "column_count" :1 ,
40- "columns" : [
41- {
42- "name" :"test_value" ,
43- "type_text" :"INT" ,
44- "type_name" :"INT" ,
45- "position" :0 ,
46- }
47- ],
48- },
49- "total_chunk_count" :1 ,
50- "chunks" : [{"chunk_index" :0 ,"row_offset" :0 ,"row_count" :1 }],
51- "total_row_count" :1 ,
52- "truncated" :False ,
53- },
54- "result" : {
55- "chunk_index" :0 ,
56- "row_offset" :0 ,
57- "row_count" :1 ,
58- "data_array" : [["1" ]],
59- },
60- }
61-
6230@pytest .fixture
6331def execute_response (self ):
6432"""Create a sample execute response."""
@@ -72,78 +40,35 @@ def execute_response(self):
7240 ("test_value" ,"INT" ,None ,None ,None ,None ,None )
7341 ]
7442mock_response .is_staging_operation = False
75- mock_response .sea_response = {
76- "statement_id" :"test-statement-123" ,
77- "status" : {"state" :"SUCCEEDED" },
78- "result" : {"data_array" : [["1" ]]},
79- }
8043return mock_response
8144
82- def test_init_with_sea_response (
83- self ,mock_connection ,mock_sea_client ,sea_response
84- ):
85- """Test initializing SeaResultSet with a SEA response."""
86- result_set = SeaResultSet (
87- connection = mock_connection ,
88- sea_client = mock_sea_client ,
89- sea_response = sea_response ,
90- buffer_size_bytes = 1000 ,
91- arraysize = 100 ,
92- )
93-
94- # Verify basic properties
95- assert result_set .statement_id == "test-statement-123"
96- assert result_set .status == CommandState .SUCCEEDED
97- assert result_set .command_id .guid == "test-statement-123"
98- assert result_set .command_id .backend_type == BackendType .SEA
99- assert result_set .connection == mock_connection
100- assert result_set .backend == mock_sea_client
101- assert result_set .buffer_size_bytes == 1000
102- assert result_set .arraysize == 100
103- assert result_set ._response == sea_response
104-
10545def test_init_with_execute_response (
10646self ,mock_connection ,mock_sea_client ,execute_response
10747 ):
10848"""Test initializing SeaResultSet with an execute response."""
10949result_set = SeaResultSet (
11050connection = mock_connection ,
111- sea_client = mock_sea_client ,
11251execute_response = execute_response ,
52+ sea_client = mock_sea_client ,
11353buffer_size_bytes = 1000 ,
11454arraysize = 100 ,
11555 )
11656
11757# Verify basic properties
118- assert result_set .statement_id == "test-statement-123"
58+ assert result_set .command_id == execute_response . command_id
11959assert result_set .status == CommandState .SUCCEEDED
120- assert result_set .command_id .guid == "test-statement-123"
121- assert result_set .command_id .backend_type == BackendType .SEA
12260assert result_set .connection == mock_connection
12361assert result_set .backend == mock_sea_client
12462assert result_set .buffer_size_bytes == 1000
12563assert result_set .arraysize == 100
126- assert result_set ._response == execute_response .sea_response
64+ assert result_set .description == execute_response .description
12765
128- def test_init_with_no_response (self ,mock_connection ,mock_sea_client ):
129- """Test that initialization fails when neither response type is provided."""
130- with pytest .raises (ValueError )as excinfo :
131- SeaResultSet (
132- connection = mock_connection ,
133- sea_client = mock_sea_client ,
134- buffer_size_bytes = 1000 ,
135- arraysize = 100 ,
136- )
137- assert "Either execute_response or sea_response must be provided" in str (
138- excinfo .value
139- )
140-
141- def test_close (self ,mock_connection ,mock_sea_client ,sea_response ):
66+ def test_close (self ,mock_connection ,mock_sea_client ,execute_response ):
14267"""Test closing a result set."""
14368result_set = SeaResultSet (
14469connection = mock_connection ,
70+ execute_response = execute_response ,
14571sea_client = mock_sea_client ,
146- sea_response = sea_response ,
14772buffer_size_bytes = 1000 ,
14873arraysize = 100 ,
14974 )
@@ -157,13 +82,13 @@ def test_close(self, mock_connection, mock_sea_client, sea_response):
15782assert result_set .status == CommandState .CLOSED
15883
15984def test_close_when_already_closed_server_side (
160- self ,mock_connection ,mock_sea_client ,sea_response
85+ self ,mock_connection ,mock_sea_client ,execute_response
16186 ):
16287"""Test closing a result set that has already been closed server-side."""
16388result_set = SeaResultSet (
16489connection = mock_connection ,
90+ execute_response = execute_response ,
16591sea_client = mock_sea_client ,
166- sea_response = sea_response ,
16792buffer_size_bytes = 1000 ,
16893arraysize = 100 ,
16994 )
@@ -178,14 +103,14 @@ def test_close_when_already_closed_server_side(
178103assert result_set .status == CommandState .CLOSED
179104
180105def test_close_when_connection_closed (
181- self ,mock_connection ,mock_sea_client ,sea_response
106+ self ,mock_connection ,mock_sea_client ,execute_response
182107 ):
183108"""Test closing a result set when the connection is closed."""
184109mock_connection .open = False
185110result_set = SeaResultSet (
186111connection = mock_connection ,
112+ execute_response = execute_response ,
187113sea_client = mock_sea_client ,
188- sea_response = sea_response ,
189114buffer_size_bytes = 1000 ,
190115arraysize = 100 ,
191116 )
@@ -199,13 +124,13 @@ def test_close_when_connection_closed(
199124assert result_set .status == CommandState .CLOSED
200125
201126def test_unimplemented_methods (
202- self ,mock_connection ,mock_sea_client ,sea_response
127+ self ,mock_connection ,mock_sea_client ,execute_response
203128 ):
204129"""Test that unimplemented methods raise NotImplementedError."""
205130result_set = SeaResultSet (
206131connection = mock_connection ,
132+ execute_response = execute_response ,
207133sea_client = mock_sea_client ,
208- sea_response = sea_response ,
209134buffer_size_bytes = 1000 ,
210135arraysize = 100 ,
211136 )
@@ -258,18 +183,18 @@ def test_unimplemented_methods(
258183pass
259184
260185def test_fill_results_buffer_not_implemented (
261- self ,mock_connection ,mock_sea_client ,sea_response
186+ self ,mock_connection ,mock_sea_client ,execute_response
262187 ):
263188"""Test that _fill_results_buffer raises NotImplementedError."""
264189result_set = SeaResultSet (
265190connection = mock_connection ,
191+ execute_response = execute_response ,
266192sea_client = mock_sea_client ,
267- sea_response = sea_response ,
268193buffer_size_bytes = 1000 ,
269194arraysize = 100 ,
270195 )
271196
272197with pytest .raises (
273198NotImplementedError ,match = "fetchone is not implemented for SEA backend"
274199 ):
275- result_set ._fill_results_buffer ()
200+ result_set ._fill_results_buffer ()