@@ -364,7 +364,7 @@ def test_init_with_valid_initial_link(
364364
365365 # Verify attributes
366366 assert queue ._statement_id == "test-statement-123"
367- assert queue ._current_chunk_link == sample_external_link
367+ assert queue ._current_chunk_index == 0
368368
369369 @patch ("databricks.sql.backend.sea.queue.ResultFileDownloadManager" )
370370 @patch ("databricks.sql.backend.sea.queue.logger" )
@@ -390,91 +390,31 @@ def test_init_no_initial_links(
390390 )
391391 assert queue .table is None
392392
393- @patch ("databricks.sql.backend.sea.queue.logger" )
394- def test_progress_chunk_link_no_current_link (self , mock_logger ):
395- """Test _progress_chunk_link with no current link."""
396- # Create a queue instance without initializing
397- queue = Mock (spec = SeaCloudFetchQueue )
398- queue ._current_chunk_link = None
399-
400- # Call the method directly
401- result = SeaCloudFetchQueue ._progress_chunk_link (queue )
402-
403- # Verify the result is None
404- assert result is None
405-
406- @patch ("databricks.sql.backend.sea.queue.logger" )
407- def test_progress_chunk_link_no_next_chunk (self , mock_logger ):
408- """Test _progress_chunk_link with no next chunk index."""
409- # Create a queue instance without initializing
410- queue = Mock (spec = SeaCloudFetchQueue )
411- queue ._current_chunk_link = ExternalLink (
412- external_link = "https://example.com/data/chunk0" ,
413- expiration = "2025-07-03T05:51:18.118009" ,
414- row_count = 100 ,
415- byte_count = 1024 ,
416- row_offset = 0 ,
417- chunk_index = 0 ,
418- next_chunk_index = None ,
419- http_headers = {"Authorization" : "Bearer token123" },
420- )
421-
422- # Call the method directly
423- result = SeaCloudFetchQueue ._progress_chunk_link (queue )
424-
425- # Verify the result is None
426- assert result is None
427- assert queue ._current_chunk_link is None
428-
429- @patch ("databricks.sql.backend.sea.queue.logger" )
430- def test_create_next_table_no_current_link (self , mock_logger ):
431- """Test _create_next_table with no current link."""
432- # Create a queue instance without initializing
433- queue = Mock (spec = SeaCloudFetchQueue )
434- queue ._current_chunk_link = None
435-
436- # Call the method directly
437- result = SeaCloudFetchQueue ._create_next_table (queue )
438-
439- # Verify debug message was logged
440- mock_logger .debug .assert_called_with (
441- "SeaCloudFetchQueue: No current chunk link, returning"
442- )
443-
444- # Verify the result is None
445- assert result is None
446-
447393 @patch ("databricks.sql.backend.sea.queue.logger" )
448394 def test_create_next_table_success (self , mock_logger ):
449395 """Test _create_next_table with successful table creation."""
450396 # Create a queue instance without initializing
451397 queue = Mock (spec = SeaCloudFetchQueue )
452- queue ._current_chunk_link = ExternalLink (
453- external_link = "https://example.com/data/chunk0" ,
454- expiration = "2025-07-03T05:51:18.118009" ,
455- row_count = 100 ,
456- byte_count = 1024 ,
457- row_offset = 50 ,
458- chunk_index = 0 ,
459- next_chunk_index = 1 ,
460- http_headers = {"Authorization" : "Bearer token123" },
461- )
398+ queue ._current_chunk_index = 0
462399 queue .download_manager = Mock ()
463400
464401 # Mock the dependencies
465402 mock_table = Mock ()
466- queue ._create_table_at_offset = Mock (return_value = mock_table )
403+ mock_chunk_link = Mock ()
404+ queue ._get_chunk_link = Mock (return_value = mock_chunk_link )
467405 queue ._create_table_from_link = Mock (return_value = mock_table )
468- queue ._progress_chunk_link = Mock ()
469406
470407 # Call the method directly
471408 result = SeaCloudFetchQueue ._create_next_table (queue )
472409
473- # Verify the table was created
474- queue ._create_table_from_link .assert_called_once_with (queue ._current_chunk_link )
410+ # Verify the chunk index was incremented
411+ assert queue ._current_chunk_index == 1
412+
413+ # Verify the chunk link was retrieved
414+ queue ._get_chunk_link .assert_called_once_with (1 )
475415
476- # Verify progress was called
477- queue ._progress_chunk_link . assert_called_once ( )
416+ # Verify the table was created from the link
417+ queue ._create_table_from_link . assert_called_once_with ( mock_chunk_link )
478418
479419 # Verify the result is the table
480420 assert result == mock_table
0 commit comments