@@ -27,38 +27,6 @@ def mock_sea_client(self):
2727 """Create a mock SEA client."""
2828 return 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
6331 def 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 ]
7442 mock_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- }
8043 return 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-
10545 def test_init_with_execute_response (
10646 self , mock_connection , mock_sea_client , execute_response
10747 ):
10848 """Test initializing SeaResultSet with an execute response."""
10949 result_set = SeaResultSet (
11050 connection = mock_connection ,
111- sea_client = mock_sea_client ,
11251 execute_response = execute_response ,
52+ sea_client = mock_sea_client ,
11353 buffer_size_bytes = 1000 ,
11454 arraysize = 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
11959 assert 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
12260 assert result_set .connection == mock_connection
12361 assert result_set .backend == mock_sea_client
12462 assert result_set .buffer_size_bytes == 1000
12563 assert 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."""
14368 result_set = SeaResultSet (
14469 connection = mock_connection ,
70+ execute_response = execute_response ,
14571 sea_client = mock_sea_client ,
146- sea_response = sea_response ,
14772 buffer_size_bytes = 1000 ,
14873 arraysize = 100 ,
14974 )
@@ -157,13 +82,13 @@ def test_close(self, mock_connection, mock_sea_client, sea_response):
15782 assert result_set .status == CommandState .CLOSED
15883
15984 def 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."""
16388 result_set = SeaResultSet (
16489 connection = mock_connection ,
90+ execute_response = execute_response ,
16591 sea_client = mock_sea_client ,
166- sea_response = sea_response ,
16792 buffer_size_bytes = 1000 ,
16893 arraysize = 100 ,
16994 )
@@ -178,14 +103,14 @@ def test_close_when_already_closed_server_side(
178103 assert result_set .status == CommandState .CLOSED
179104
180105 def 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."""
184109 mock_connection .open = False
185110 result_set = SeaResultSet (
186111 connection = mock_connection ,
112+ execute_response = execute_response ,
187113 sea_client = mock_sea_client ,
188- sea_response = sea_response ,
189114 buffer_size_bytes = 1000 ,
190115 arraysize = 100 ,
191116 )
@@ -199,13 +124,13 @@ def test_close_when_connection_closed(
199124 assert result_set .status == CommandState .CLOSED
200125
201126 def 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."""
205130 result_set = SeaResultSet (
206131 connection = mock_connection ,
132+ execute_response = execute_response ,
207133 sea_client = mock_sea_client ,
208- sea_response = sea_response ,
209134 buffer_size_bytes = 1000 ,
210135 arraysize = 100 ,
211136 )
@@ -258,18 +183,18 @@ def test_unimplemented_methods(
258183 pass
259184
260185 def 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."""
264189 result_set = SeaResultSet (
265190 connection = mock_connection ,
191+ execute_response = execute_response ,
266192 sea_client = mock_sea_client ,
267- sea_response = sea_response ,
268193 buffer_size_bytes = 1000 ,
269194 arraysize = 100 ,
270195 )
271196
272197 with pytest .raises (
273198 NotImplementedError , match = "fetchone is not implemented for SEA backend"
274199 ):
275- result_set ._fill_results_buffer ()
200+ result_set ._fill_results_buffer ()
0 commit comments