@@ -365,6 +365,92 @@ async def fake_retry_operation_async(**kwargs):
365365 asyncio .run (run ())
366366
367367
368+ def test_sync_batch_fetch_manager_bounds_operation_name_for_paginated_path (
369+ monkeypatch ,
370+ ):
371+ manager = sync_batch_fetch_module .BatchFetchManager (_DummyClient ())
372+ long_job_id = " \n " + ("x" * 500 ) + "\t "
373+ captured = {}
374+
375+ monkeypatch .setattr (
376+ manager ,
377+ "start" ,
378+ lambda params : SimpleNamespace (job_id = long_job_id ),
379+ )
380+
381+ def fake_poll_until_terminal_status (** kwargs ):
382+ operation_name = kwargs ["operation_name" ]
383+ _assert_valid_operation_name (operation_name )
384+ captured ["poll_operation_name" ] = operation_name
385+ return "completed"
386+
387+ def fake_collect_paginated_results (** kwargs ):
388+ operation_name = kwargs ["operation_name" ]
389+ _assert_valid_operation_name (operation_name )
390+ captured ["collect_operation_name" ] = operation_name
391+
392+ monkeypatch .setattr (
393+ sync_batch_fetch_module ,
394+ "poll_until_terminal_status" ,
395+ fake_poll_until_terminal_status ,
396+ )
397+ monkeypatch .setattr (
398+ sync_batch_fetch_module ,
399+ "collect_paginated_results" ,
400+ fake_collect_paginated_results ,
401+ )
402+
403+ result = manager .start_and_wait (params = object (), return_all_pages = True ) # type: ignore[arg-type]
404+
405+ assert result .status == "completed"
406+ assert captured ["collect_operation_name" ] == captured ["poll_operation_name" ]
407+
408+
409+ def test_async_batch_fetch_manager_bounds_operation_name_for_paginated_path (
410+ monkeypatch ,
411+ ):
412+ async def run () -> None :
413+ manager = async_batch_fetch_module .BatchFetchManager (_DummyClient ())
414+ long_job_id = " \n " + ("x" * 500 ) + "\t "
415+ captured = {}
416+
417+ async def fake_start (params ):
418+ return SimpleNamespace (job_id = long_job_id )
419+
420+ async def fake_poll_until_terminal_status_async (** kwargs ):
421+ operation_name = kwargs ["operation_name" ]
422+ _assert_valid_operation_name (operation_name )
423+ captured ["poll_operation_name" ] = operation_name
424+ return "completed"
425+
426+ async def fake_collect_paginated_results_async (** kwargs ):
427+ operation_name = kwargs ["operation_name" ]
428+ _assert_valid_operation_name (operation_name )
429+ captured ["collect_operation_name" ] = operation_name
430+
431+ monkeypatch .setattr (manager , "start" , fake_start )
432+ monkeypatch .setattr (
433+ async_batch_fetch_module ,
434+ "poll_until_terminal_status_async" ,
435+ fake_poll_until_terminal_status_async ,
436+ )
437+ monkeypatch .setattr (
438+ async_batch_fetch_module ,
439+ "collect_paginated_results_async" ,
440+ fake_collect_paginated_results_async ,
441+ )
442+
443+ result = await manager .start_and_wait (
444+ params = object (), # type: ignore[arg-type]
445+ return_all_pages = True ,
446+ )
447+
448+ assert result .status == "completed"
449+ assert captured ["collect_operation_name" ] == captured ["poll_operation_name" ]
450+
451+ asyncio .run (run ())
452+
453+
368454def test_sync_web_crawl_manager_bounds_operation_name_for_fetch_retry_path (monkeypatch ):
369455 manager = sync_web_crawl_module .WebCrawlManager (_DummyClient ())
370456 long_job_id = " \n " + ("x" * 500 ) + "\t "
@@ -455,6 +541,88 @@ async def fake_retry_operation_async(**kwargs):
455541 asyncio .run (run ())
456542
457543
544+ def test_sync_web_crawl_manager_bounds_operation_name_for_paginated_path (monkeypatch ):
545+ manager = sync_web_crawl_module .WebCrawlManager (_DummyClient ())
546+ long_job_id = " \n " + ("x" * 500 ) + "\t "
547+ captured = {}
548+
549+ monkeypatch .setattr (
550+ manager ,
551+ "start" ,
552+ lambda params : SimpleNamespace (job_id = long_job_id ),
553+ )
554+
555+ def fake_poll_until_terminal_status (** kwargs ):
556+ operation_name = kwargs ["operation_name" ]
557+ _assert_valid_operation_name (operation_name )
558+ captured ["poll_operation_name" ] = operation_name
559+ return "completed"
560+
561+ def fake_collect_paginated_results (** kwargs ):
562+ operation_name = kwargs ["operation_name" ]
563+ _assert_valid_operation_name (operation_name )
564+ captured ["collect_operation_name" ] = operation_name
565+
566+ monkeypatch .setattr (
567+ sync_web_crawl_module ,
568+ "poll_until_terminal_status" ,
569+ fake_poll_until_terminal_status ,
570+ )
571+ monkeypatch .setattr (
572+ sync_web_crawl_module ,
573+ "collect_paginated_results" ,
574+ fake_collect_paginated_results ,
575+ )
576+
577+ result = manager .start_and_wait (params = object (), return_all_pages = True ) # type: ignore[arg-type]
578+
579+ assert result .status == "completed"
580+ assert captured ["collect_operation_name" ] == captured ["poll_operation_name" ]
581+
582+
583+ def test_async_web_crawl_manager_bounds_operation_name_for_paginated_path (monkeypatch ):
584+ async def run () -> None :
585+ manager = async_web_crawl_module .WebCrawlManager (_DummyClient ())
586+ long_job_id = " \n " + ("x" * 500 ) + "\t "
587+ captured = {}
588+
589+ async def fake_start (params ):
590+ return SimpleNamespace (job_id = long_job_id )
591+
592+ async def fake_poll_until_terminal_status_async (** kwargs ):
593+ operation_name = kwargs ["operation_name" ]
594+ _assert_valid_operation_name (operation_name )
595+ captured ["poll_operation_name" ] = operation_name
596+ return "completed"
597+
598+ async def fake_collect_paginated_results_async (** kwargs ):
599+ operation_name = kwargs ["operation_name" ]
600+ _assert_valid_operation_name (operation_name )
601+ captured ["collect_operation_name" ] = operation_name
602+
603+ monkeypatch .setattr (manager , "start" , fake_start )
604+ monkeypatch .setattr (
605+ async_web_crawl_module ,
606+ "poll_until_terminal_status_async" ,
607+ fake_poll_until_terminal_status_async ,
608+ )
609+ monkeypatch .setattr (
610+ async_web_crawl_module ,
611+ "collect_paginated_results_async" ,
612+ fake_collect_paginated_results_async ,
613+ )
614+
615+ result = await manager .start_and_wait (
616+ params = object (), # type: ignore[arg-type]
617+ return_all_pages = True ,
618+ )
619+
620+ assert result .status == "completed"
621+ assert captured ["collect_operation_name" ] == captured ["poll_operation_name" ]
622+
623+ asyncio .run (run ())
624+
625+
458626def test_sync_batch_scrape_manager_bounds_operation_name_for_fetch_retry_path (
459627 monkeypatch ,
460628):
@@ -547,6 +715,92 @@ async def fake_retry_operation_async(**kwargs):
547715 asyncio .run (run ())
548716
549717
718+ def test_sync_batch_scrape_manager_bounds_operation_name_for_paginated_path (
719+ monkeypatch ,
720+ ):
721+ manager = sync_scrape_module .BatchScrapeManager (_DummyClient ())
722+ long_job_id = " \n " + ("x" * 500 ) + "\t "
723+ captured = {}
724+
725+ monkeypatch .setattr (
726+ manager ,
727+ "start" ,
728+ lambda params : SimpleNamespace (job_id = long_job_id ),
729+ )
730+
731+ def fake_poll_until_terminal_status (** kwargs ):
732+ operation_name = kwargs ["operation_name" ]
733+ _assert_valid_operation_name (operation_name )
734+ captured ["poll_operation_name" ] = operation_name
735+ return "completed"
736+
737+ def fake_collect_paginated_results (** kwargs ):
738+ operation_name = kwargs ["operation_name" ]
739+ _assert_valid_operation_name (operation_name )
740+ captured ["collect_operation_name" ] = operation_name
741+
742+ monkeypatch .setattr (
743+ sync_scrape_module ,
744+ "poll_until_terminal_status" ,
745+ fake_poll_until_terminal_status ,
746+ )
747+ monkeypatch .setattr (
748+ sync_scrape_module ,
749+ "collect_paginated_results" ,
750+ fake_collect_paginated_results ,
751+ )
752+
753+ result = manager .start_and_wait (params = object (), return_all_pages = True ) # type: ignore[arg-type]
754+
755+ assert result .status == "completed"
756+ assert captured ["collect_operation_name" ] == captured ["poll_operation_name" ]
757+
758+
759+ def test_async_batch_scrape_manager_bounds_operation_name_for_paginated_path (
760+ monkeypatch ,
761+ ):
762+ async def run () -> None :
763+ manager = async_scrape_module .BatchScrapeManager (_DummyClient ())
764+ long_job_id = " \n " + ("x" * 500 ) + "\t "
765+ captured = {}
766+
767+ async def fake_start (params ):
768+ return SimpleNamespace (job_id = long_job_id )
769+
770+ async def fake_poll_until_terminal_status_async (** kwargs ):
771+ operation_name = kwargs ["operation_name" ]
772+ _assert_valid_operation_name (operation_name )
773+ captured ["poll_operation_name" ] = operation_name
774+ return "completed"
775+
776+ async def fake_collect_paginated_results_async (** kwargs ):
777+ operation_name = kwargs ["operation_name" ]
778+ _assert_valid_operation_name (operation_name )
779+ captured ["collect_operation_name" ] = operation_name
780+
781+ monkeypatch .setattr (manager , "start" , fake_start )
782+ monkeypatch .setattr (
783+ async_scrape_module ,
784+ "poll_until_terminal_status_async" ,
785+ fake_poll_until_terminal_status_async ,
786+ )
787+ monkeypatch .setattr (
788+ async_scrape_module ,
789+ "collect_paginated_results_async" ,
790+ fake_collect_paginated_results_async ,
791+ )
792+
793+ result = await manager .start_and_wait (
794+ params = object (), # type: ignore[arg-type]
795+ return_all_pages = True ,
796+ )
797+
798+ assert result .status == "completed"
799+ assert captured ["collect_operation_name" ] == captured ["poll_operation_name" ]
800+
801+ asyncio .run (run ())
802+
803+
550804def test_sync_browser_use_manager_bounds_operation_name_in_wait_helper (monkeypatch ):
551805 manager = sync_browser_use_module .BrowserUseManager (_DummyClient ())
552806 long_job_id = " \n " + ("x" * 500 ) + "\t "
0 commit comments