@@ -27,38 +27,6 @@ def mock_sea_client(self):
27
27
"""Create a mock SEA client."""
28
28
return Mock ()
29
29
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
-
62
30
@pytest .fixture
63
31
def execute_response (self ):
64
32
"""Create a sample execute response."""
@@ -72,78 +40,35 @@ def execute_response(self):
72
40
("test_value" , "INT" , None , None , None , None , None )
73
41
]
74
42
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
- }
80
43
return mock_response
81
44
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
-
105
45
def test_init_with_execute_response (
106
46
self , mock_connection , mock_sea_client , execute_response
107
47
):
108
48
"""Test initializing SeaResultSet with an execute response."""
109
49
result_set = SeaResultSet (
110
50
connection = mock_connection ,
111
- sea_client = mock_sea_client ,
112
51
execute_response = execute_response ,
52
+ sea_client = mock_sea_client ,
113
53
buffer_size_bytes = 1000 ,
114
54
arraysize = 100 ,
115
55
)
116
56
117
57
# Verify basic properties
118
- assert result_set .statement_id == "test-statement-123"
58
+ assert result_set .command_id == execute_response . command_id
119
59
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
122
60
assert result_set .connection == mock_connection
123
61
assert result_set .backend == mock_sea_client
124
62
assert result_set .buffer_size_bytes == 1000
125
63
assert result_set .arraysize == 100
126
- assert result_set ._response == execute_response .sea_response
64
+ assert result_set .description == execute_response .description
127
65
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 ):
142
67
"""Test closing a result set."""
143
68
result_set = SeaResultSet (
144
69
connection = mock_connection ,
70
+ execute_response = execute_response ,
145
71
sea_client = mock_sea_client ,
146
- sea_response = sea_response ,
147
72
buffer_size_bytes = 1000 ,
148
73
arraysize = 100 ,
149
74
)
@@ -157,13 +82,13 @@ def test_close(self, mock_connection, mock_sea_client, sea_response):
157
82
assert result_set .status == CommandState .CLOSED
158
83
159
84
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
161
86
):
162
87
"""Test closing a result set that has already been closed server-side."""
163
88
result_set = SeaResultSet (
164
89
connection = mock_connection ,
90
+ execute_response = execute_response ,
165
91
sea_client = mock_sea_client ,
166
- sea_response = sea_response ,
167
92
buffer_size_bytes = 1000 ,
168
93
arraysize = 100 ,
169
94
)
@@ -178,14 +103,14 @@ def test_close_when_already_closed_server_side(
178
103
assert result_set .status == CommandState .CLOSED
179
104
180
105
def test_close_when_connection_closed (
181
- self , mock_connection , mock_sea_client , sea_response
106
+ self , mock_connection , mock_sea_client , execute_response
182
107
):
183
108
"""Test closing a result set when the connection is closed."""
184
109
mock_connection .open = False
185
110
result_set = SeaResultSet (
186
111
connection = mock_connection ,
112
+ execute_response = execute_response ,
187
113
sea_client = mock_sea_client ,
188
- sea_response = sea_response ,
189
114
buffer_size_bytes = 1000 ,
190
115
arraysize = 100 ,
191
116
)
@@ -199,13 +124,13 @@ def test_close_when_connection_closed(
199
124
assert result_set .status == CommandState .CLOSED
200
125
201
126
def test_unimplemented_methods (
202
- self , mock_connection , mock_sea_client , sea_response
127
+ self , mock_connection , mock_sea_client , execute_response
203
128
):
204
129
"""Test that unimplemented methods raise NotImplementedError."""
205
130
result_set = SeaResultSet (
206
131
connection = mock_connection ,
132
+ execute_response = execute_response ,
207
133
sea_client = mock_sea_client ,
208
- sea_response = sea_response ,
209
134
buffer_size_bytes = 1000 ,
210
135
arraysize = 100 ,
211
136
)
@@ -258,18 +183,18 @@ def test_unimplemented_methods(
258
183
pass
259
184
260
185
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
262
187
):
263
188
"""Test that _fill_results_buffer raises NotImplementedError."""
264
189
result_set = SeaResultSet (
265
190
connection = mock_connection ,
191
+ execute_response = execute_response ,
266
192
sea_client = mock_sea_client ,
267
- sea_response = sea_response ,
268
193
buffer_size_bytes = 1000 ,
269
194
arraysize = 100 ,
270
195
)
271
196
272
197
with pytest .raises (
273
198
NotImplementedError , match = "fetchone is not implemented for SEA backend"
274
199
):
275
- result_set ._fill_results_buffer ()
200
+ result_set ._fill_results_buffer ()
0 commit comments