77"""
88
99import pytest
10- from unittest .mock import Mock , patch
10+ from unittest .mock import Mock , patch , MagicMock
1111
1212from databricks .sql .backend .sea .queue import (
1313 JsonQueue ,
@@ -184,6 +184,7 @@ def description(self):
184184 def test_build_queue_json_array (self , json_manifest , sample_data ):
185185 """Test building a JSON array queue."""
186186 result_data = ResultData (data = sample_data )
187+ mock_http_client = MagicMock ()
187188
188189 queue = SeaResultSetQueueFactory .build_queue (
189190 result_data = result_data ,
@@ -194,6 +195,7 @@ def test_build_queue_json_array(self, json_manifest, sample_data):
194195 max_download_threads = 10 ,
195196 sea_client = Mock (),
196197 lz4_compressed = False ,
198+ http_client = mock_http_client ,
197199 )
198200
199201 assert isinstance (queue , JsonQueue )
@@ -217,6 +219,8 @@ def test_build_queue_arrow_stream(
217219 ]
218220 result_data = ResultData (data = None , external_links = external_links )
219221
222+ mock_http_client = MagicMock ()
223+
220224 with patch (
221225 "databricks.sql.backend.sea.queue.ResultFileDownloadManager"
222226 ), patch .object (SeaCloudFetchQueue , "_create_next_table" , return_value = None ):
@@ -229,13 +233,15 @@ def test_build_queue_arrow_stream(
229233 max_download_threads = 10 ,
230234 sea_client = mock_sea_client ,
231235 lz4_compressed = False ,
236+ http_client = mock_http_client ,
232237 )
233238
234239 assert isinstance (queue , SeaCloudFetchQueue )
235240
236241 def test_build_queue_invalid_format (self , invalid_manifest ):
237242 """Test building a queue with invalid format."""
238243 result_data = ResultData (data = [])
244+ mock_http_client = MagicMock ()
239245
240246 with pytest .raises (ProgrammingError , match = "Invalid result format" ):
241247 SeaResultSetQueueFactory .build_queue (
@@ -247,6 +253,7 @@ def test_build_queue_invalid_format(self, invalid_manifest):
247253 max_download_threads = 10 ,
248254 sea_client = Mock (),
249255 lz4_compressed = False ,
256+ http_client = mock_http_client ,
250257 )
251258
252259
@@ -339,6 +346,7 @@ def test_init_with_valid_initial_link(
339346 ):
340347 """Test initialization with valid initial link."""
341348 # Create a queue with valid initial link
349+ mock_http_client = MagicMock ()
342350 with patch .object (SeaCloudFetchQueue , "_create_next_table" , return_value = None ):
343351 queue = SeaCloudFetchQueue (
344352 result_data = ResultData (external_links = [sample_external_link ]),
@@ -349,6 +357,7 @@ def test_init_with_valid_initial_link(
349357 total_chunk_count = 1 ,
350358 lz4_compressed = False ,
351359 description = description ,
360+ http_client = mock_http_client ,
352361 )
353362
354363 # Verify attributes
@@ -367,6 +376,7 @@ def test_init_no_initial_links(
367376 ):
368377 """Test initialization with no initial links."""
369378 # Create a queue with empty initial links
379+ mock_http_client = MagicMock ()
370380 queue = SeaCloudFetchQueue (
371381 result_data = ResultData (external_links = []),
372382 max_download_threads = 5 ,
@@ -376,6 +386,7 @@ def test_init_no_initial_links(
376386 total_chunk_count = 0 ,
377387 lz4_compressed = False ,
378388 description = description ,
389+ http_client = mock_http_client ,
379390 )
380391 assert queue .table is None
381392
@@ -462,7 +473,7 @@ def test_hybrid_disposition_with_attachment(
462473 # Create result data with attachment
463474 attachment_data = b"mock_arrow_data"
464475 result_data = ResultData (attachment = attachment_data )
465-
476+ mock_http_client = MagicMock ()
466477 # Build queue
467478 queue = SeaResultSetQueueFactory .build_queue (
468479 result_data = result_data ,
@@ -473,6 +484,7 @@ def test_hybrid_disposition_with_attachment(
473484 max_download_threads = 10 ,
474485 sea_client = mock_sea_client ,
475486 lz4_compressed = False ,
487+ http_client = mock_http_client ,
476488 )
477489
478490 # Verify ArrowQueue was created
@@ -508,7 +520,8 @@ def test_hybrid_disposition_with_external_links(
508520 # Create result data with external links but no attachment
509521 result_data = ResultData (external_links = external_links , attachment = None )
510522
511- # Build queue
523+ # Build queue
524+ mock_http_client = MagicMock ()
512525 queue = SeaResultSetQueueFactory .build_queue (
513526 result_data = result_data ,
514527 manifest = arrow_manifest ,
@@ -518,6 +531,7 @@ def test_hybrid_disposition_with_external_links(
518531 max_download_threads = 10 ,
519532 sea_client = mock_sea_client ,
520533 lz4_compressed = False ,
534+ http_client = mock_http_client ,
521535 )
522536
523537 # Verify SeaCloudFetchQueue was created
@@ -548,7 +562,7 @@ def test_hybrid_disposition_with_compressed_attachment(
548562
549563 # Create result data with attachment
550564 result_data = ResultData (attachment = compressed_data )
551-
565+ mock_http_client = MagicMock ()
552566 # Build queue with lz4_compressed=True
553567 queue = SeaResultSetQueueFactory .build_queue (
554568 result_data = result_data ,
@@ -559,6 +573,7 @@ def test_hybrid_disposition_with_compressed_attachment(
559573 max_download_threads = 10 ,
560574 sea_client = mock_sea_client ,
561575 lz4_compressed = True ,
576+ http_client = mock_http_client ,
562577 )
563578
564579 # Verify ArrowQueue was created with decompressed data
0 commit comments