@@ -419,15 +419,15 @@ def test_to_dataframe_by_page(class_under_test, mock_client):
419419 ]
420420 avro_schema  =  _bq_to_avro_schema (bq_columns )
421421 read_session  =  _generate_read_session (avro_schema )
422-  bq_blocks_1  =  [
423-  [{"int_col" : 123 , "bool_col" : True }, {"int_col" : 234 , "bool_col" : False }],
424-  [{"int_col" : 345 , "bool_col" : True }, {"int_col" : 456 , "bool_col" : False }],
425-  ]
422+  block_1  =  [{"int_col" : 123 , "bool_col" : True }, {"int_col" : 234 , "bool_col" : False }]
423+  block_2  =  [{"int_col" : 345 , "bool_col" : True }, {"int_col" : 456 , "bool_col" : False }]
424+  block_3  =  [{"int_col" : 567 , "bool_col" : True }, {"int_col" : 789 , "bool_col" : False }]
425+  block_4  =  [{"int_col" : 890 , "bool_col" : True }]
426+  # Break blocks into two groups to test that iteration continues across 
427+  # reconnection. 
428+  bq_blocks_1  =  [block_1 , block_2 ]
429+  bq_blocks_2  =  [block_3 , block_4 ]
426430 avro_blocks_1  =  _bq_to_avro_blocks (bq_blocks_1 , avro_schema )
427-  bq_blocks_2  =  [
428-  [{"int_col" : 567 , "bool_col" : True }, {"int_col" : 789 , "bool_col" : False }],
429-  [{"int_col" : 890 , "bool_col" : True }],
430-  ]
431431 avro_blocks_2  =  _bq_to_avro_blocks (bq_blocks_2 , avro_schema )
432432
433433 mock_client .read_rows .return_value  =  avro_blocks_2 
@@ -447,36 +447,33 @@ def test_to_dataframe_by_page(class_under_test, mock_client):
447447 page_1  =  next (pages )
448448 pandas .testing .assert_frame_equal (
449449 page_1 .to_dataframe ().reset_index (drop = True ),
450-  pandas .DataFrame (
451-  {"int_col" : [123 , 234 ], "bool_col" : [True , False ]},
452-  columns = ["int_col" , "bool_col" ],
453-  ).reset_index (drop = True ),
450+  pandas .DataFrame (block_1 , columns = ["int_col" , "bool_col" ]).reset_index (
451+  drop = True 
452+  ),
454453 )
455454
456455 page_2  =  next (pages )
457456 pandas .testing .assert_frame_equal (
458457 page_2 .to_dataframe ().reset_index (drop = True ),
459-  pandas .DataFrame (
460-  {"int_col" : [345 , 456 ], "bool_col" : [True , False ]},
461-  columns = ["int_col" , "bool_col" ],
462-  ).reset_index (drop = True ),
458+  pandas .DataFrame (block_2 , columns = ["int_col" , "bool_col" ]).reset_index (
459+  drop = True 
460+  ),
463461 )
464462
465463 page_3  =  next (pages )
466464 pandas .testing .assert_frame_equal (
467465 page_3 .to_dataframe ().reset_index (drop = True ),
468-  pandas .DataFrame (
469-  {"int_col" : [567 , 789 ], "bool_col" : [True , False ]},
470-  columns = ["int_col" , "bool_col" ],
471-  ).reset_index (drop = True ),
466+  pandas .DataFrame (block_3 , columns = ["int_col" , "bool_col" ]).reset_index (
467+  drop = True 
468+  ),
472469 )
473470
474471 page_4  =  next (pages )
475472 pandas .testing .assert_frame_equal (
476473 page_4 .to_dataframe ().reset_index (drop = True ),
477-  pandas .DataFrame (
478-  { "int_col" : [ 890 ],  "bool_col" : [ True ]},  columns = [ "int_col" ,  "bool_col" ] 
479-  ). reset_index ( drop = True ) ,
474+  pandas .DataFrame (block_4 ,  columns = [ "int_col" ,  "bool_col" ]). reset_index ( 
475+  drop = True 
476+  ),
480477 )
481478
482479
0 commit comments