11import json
2+ from decimal import Decimal
23from unittest .mock import MagicMock , patch
34
45import pytest
@@ -173,6 +174,7 @@ def test_append_empty_response(self, in_memory_rowset):
173174
174175 async def test_append_response (self , in_memory_rowset , mock_response ):
175176 """Test appending a response with data."""
177+
176178 # Create a proper aclose method
177179 async def mock_aclose ():
178180 mock_response .is_closed = True
@@ -207,6 +209,7 @@ async def test_append_response_empty_content(
207209 self , in_memory_rowset , mock_empty_response
208210 ):
209211 """Test appending a response with empty content."""
212+
210213 # Create a proper aclose method
211214 async def mock_aclose ():
212215 mock_empty_response .is_closed = True
@@ -226,6 +229,7 @@ async def test_append_response_invalid_json(
226229 self , in_memory_rowset , mock_invalid_json_response
227230 ):
228231 """Test appending a response with invalid JSON."""
232+
229233 # Create a proper aclose method
230234 async def mock_aclose ():
231235 mock_invalid_json_response .is_closed = True
@@ -245,6 +249,7 @@ async def test_append_response_missing_meta(
245249 self , in_memory_rowset , mock_missing_meta_response
246250 ):
247251 """Test appending a response with missing meta field."""
252+
248253 # Create a proper aclose method
249254 async def mock_aclose ():
250255 mock_missing_meta_response .is_closed = True
@@ -264,6 +269,7 @@ async def test_append_response_missing_data(
264269 self , in_memory_rowset , mock_missing_data_response
265270 ):
266271 """Test appending a response with missing data field."""
272+
267273 # Create a proper aclose method
268274 async def mock_aclose ():
269275 mock_missing_data_response .is_closed = True
@@ -281,6 +287,7 @@ async def mock_aclose():
281287
282288 async def test_nextset_no_more_sets (self , in_memory_rowset , mock_response ):
283289 """Test nextset when there are no more result sets."""
290+
284291 # Create a proper aclose method
285292 async def mock_aclose ():
286293 pass
@@ -296,6 +303,7 @@ async def test_nextset_with_more_sets(self, in_memory_rowset, mock_response):
296303 The implementation seems to add rowsets correctly, but behaves differently
297304 than expected when accessing them via nextset.
298305 """
306+
299307 # Create a proper aclose method
300308 async def mock_aclose ():
301309 pass
@@ -322,6 +330,7 @@ async def mock_aclose():
322330
323331 async def test_iteration (self , in_memory_rowset , mock_response ):
324332 """Test row iteration."""
333+
325334 # Create a proper aclose method
326335 async def mock_aclose ():
327336 pass
@@ -347,6 +356,7 @@ async def test_iteration_after_nextset(self, in_memory_rowset, mock_response):
347356 This test is tricky because in the mock setup, the second row set
348357 is actually empty despite us adding the same mock response.
349358 """
359+
350360 # Create a proper aclose method
351361 async def mock_aclose ():
352362 pass
@@ -410,6 +420,7 @@ async def test_empty_rowset_iteration(self, in_memory_rowset):
410420
411421 async def test_aclose (self , in_memory_rowset , mock_response ):
412422 """Test aclose method."""
423+
413424 # Create a proper aclose method
414425 async def mock_aclose ():
415426 pass
@@ -423,3 +434,23 @@ async def mock_aclose():
423434
424435 # Verify sync close was called
425436 mock_close .assert_called_once ()
437+
438+ async def test_append_response_with_decimals (
439+ self , in_memory_rowset : InMemoryAsyncRowSet , mock_decimal_bytes_stream : Response
440+ ):
441+
442+ await in_memory_rowset .append_response (mock_decimal_bytes_stream )
443+
444+ # Verify basic properties
445+ assert in_memory_rowset .row_count == 2
446+ assert len (in_memory_rowset .columns ) == 3
447+
448+ # Get the row values and check decimal values are equal
449+ rows = [row async for row in in_memory_rowset ]
450+
451+ # Verify the decimal value is correctly parsed
452+ for row in rows :
453+ assert isinstance (row [2 ], Decimal ), "Expected Decimal type"
454+ assert (
455+ str (row [2 ]) == "1231232.123459999990457054844258706536"
456+ ), "Decimal value mismatch"
0 commit comments