@@ -890,3 +890,76 @@ def test_get_columns(self, sea_client, sea_session_id, mock_cursor):
890890 cursor = mock_cursor ,
891891 )
892892 assert "Catalog name is required for get_columns" in str (excinfo .value )
893+
894+ def test_get_chunk_link (self , sea_client , mock_http_client , sea_command_id ):
895+ """Test get_chunk_link method."""
896+ # Setup mock response
897+ mock_response = {
898+ "external_links" : [
899+ {
900+ "external_link" : "https://example.com/data/chunk0" ,
901+ "expiration" : "2025-07-03T05:51:18.118009" ,
902+ "row_count" : 100 ,
903+ "byte_count" : 1024 ,
904+ "row_offset" : 0 ,
905+ "chunk_index" : 0 ,
906+ "next_chunk_index" : 1 ,
907+ "http_headers" : {"Authorization" : "Bearer token123" },
908+ }
909+ ]
910+ }
911+ mock_http_client ._make_request .return_value = mock_response
912+
913+ # Call the method
914+ result = sea_client .get_chunk_link ("test-statement-123" , 0 )
915+
916+ # Verify the HTTP client was called correctly
917+ mock_http_client ._make_request .assert_called_once_with (
918+ method = "GET" ,
919+ path = sea_client .CHUNK_PATH_WITH_ID_AND_INDEX .format (
920+ "test-statement-123" , 0
921+ ),
922+ )
923+
924+ # Verify the result
925+ assert result .external_link == "https://example.com/data/chunk0"
926+ assert result .expiration == "2025-07-03T05:51:18.118009"
927+ assert result .row_count == 100
928+ assert result .byte_count == 1024
929+ assert result .row_offset == 0
930+ assert result .chunk_index == 0
931+ assert result .next_chunk_index == 1
932+ assert result .http_headers == {"Authorization" : "Bearer token123" }
933+
934+ def test_get_chunk_link_not_found (self , sea_client , mock_http_client ):
935+ """Test get_chunk_link when the requested chunk is not found."""
936+ # Setup mock response with no matching chunk
937+ mock_response = {
938+ "external_links" : [
939+ {
940+ "external_link" : "https://example.com/data/chunk1" ,
941+ "expiration" : "2025-07-03T05:51:18.118009" ,
942+ "row_count" : 100 ,
943+ "byte_count" : 1024 ,
944+ "row_offset" : 100 ,
945+ "chunk_index" : 1 , # Different chunk index
946+ "next_chunk_index" : 2 ,
947+ "http_headers" : {"Authorization" : "Bearer token123" },
948+ }
949+ ]
950+ }
951+ mock_http_client ._make_request .return_value = mock_response
952+
953+ # Call the method and expect an exception
954+ with pytest .raises (
955+ ServerOperationError , match = "No link found for chunk index 0"
956+ ):
957+ sea_client .get_chunk_link ("test-statement-123" , 0 )
958+
959+ # Verify the HTTP client was called correctly
960+ mock_http_client ._make_request .assert_called_once_with (
961+ method = "GET" ,
962+ path = sea_client .CHUNK_PATH_WITH_ID_AND_INDEX .format (
963+ "test-statement-123" , 0
964+ ),
965+ )
0 commit comments