1111 STAGE_POSITION_NAMES ,
1212 STAGE_POSITION_VALUES ,
1313 FIBContext ,
14+ FIBImage ,
1415 _file_transferred_to ,
1516 _get_source ,
1617 _number_from_name ,
@@ -469,23 +470,24 @@ def test_file_transferred_to(
469470
470471@pytest .mark .parametrize (
471472 "test_params" ,
472- ( # Has environment | Has Project name | Has Site | Has Site name | Has Recipe | Has Recipe name | Has Activity | Has Activity name
473- # Pass case
474- (True , True , True , True , True , True , True , True ),
475- # Only one of these should be False at a given time
476- (True , True , True , True , True , True , True , False ),
477- (True , True , True , True , True , True , False , True ),
478- (True , True , True , True , True , False , True , True ),
479- (True , True , True , True , False , True , True , True ),
480- (True , True , True , False , True , True , True , True ),
481- (True , True , False , True , True , True , True , True ),
482- (True , False , True , True , True , True , True , True ),
483- (False , True , True , True , True , True , True , True ),
473+ (
474+ # Pass cases
475+ (True , True , True , True , True , True , True , True , True ), # DC images
476+ (True , True , True , True , True , True , True , True , False ), # No DC images
477+ # Only one of these, and the last one, should be False at a given time
478+ (True , True , True , True , True , True , True , False , False ), # No activity name
479+ (True , True , True , True , True , True , False , True , False ), # No activity
480+ (True , True , True , True , True , False , True , True , False ), # No recipe name
481+ (True , True , True , True , False , True , True , True , False ), # No recipe
482+ (True , True , True , False , True , True , True , True , False ), # No site name
483+ (True , True , False , True , True , True , True , True , False ), # No sites
484+ (True , False , True , True , True , True , True , True , False ), # No project name
485+ (False , True , True , True , True , True , True , True , False ), # No environment
484486 ),
485487)
486488def test_fib_autotem_context_projectdata (
487489 mocker : MockerFixture ,
488- test_params : tuple [bool , bool , bool , bool , bool , bool , bool , bool ],
490+ test_params : tuple [bool , bool , bool , bool , bool , bool , bool , bool , bool ],
489491 tmp_path : Path ,
490492 visit_dir : Path ,
491493):
@@ -499,6 +501,7 @@ def test_fib_autotem_context_projectdata(
499501 has_recipe_name ,
500502 has_activities ,
501503 has_activity_name ,
504+ has_drift_correction_images ,
502505 ) = test_params
503506
504507 # Mock the environment
@@ -532,6 +535,14 @@ def test_fib_autotem_context_projectdata(
532535 machine_config = {},
533536 token = "" ,
534537 )
538+ if has_drift_correction_images :
539+ for i in range (num_lamellae ):
540+ context ._drift_correction_images [i + 1 ] = FIBImage (
541+ images = [tmp_path / "dummy.png" ],
542+ output_file = tmp_path / "dc_image.gif" ,
543+ is_submitted = False ,
544+ )
545+
535546 context .post_transfer (mock_projectdata , environment = mock_environment )
536547
537548 # Check the success case
@@ -547,10 +558,35 @@ def test_fib_autotem_context_projectdata(
547558 has_activity_name ,
548559 )
549560 ):
550- assert mock_capture_post .call_count == num_lamellae
561+ assert mock_capture_post .call_count == num_lamellae * (
562+ 2 if has_drift_correction_images else 1
563+ )
551564 assert len (context ._site_info ) == num_lamellae
552565 for i in range (num_lamellae ):
566+ mock_capture_post .assert_any_call (
567+ base_url = mock .ANY ,
568+ router_name = "workflow_fib.router" ,
569+ function_name = "register_fib_milling_progress" ,
570+ token = mock .ANY ,
571+ instrument_name = mock .ANY ,
572+ data = mock .ANY ,
573+ session_id = mock .ANY ,
574+ )
553575 mock_logger .info .assert_any_call (f"Updating metadata for site { i + 1 } " )
576+ if has_drift_correction_images :
577+ mock_capture_post .assert_any_call (
578+ base_url = mock .ANY ,
579+ router_name = "workflow_fib.router" ,
580+ function_name = "make_gif" ,
581+ token = mock .ANY ,
582+ instrument_name = mock .ANY ,
583+ data = {
584+ "lamella_number" : i + 1 ,
585+ "images" : [str (tmp_path / "dummy.png" )],
586+ "output_file" : str (tmp_path / "dc_image.gif" ),
587+ },
588+ session_id = mock .ANY ,
589+ )
554590 # These fail cases will return an empty dict and not call "post_transfer"
555591 if not has_environment :
556592 mock_logger .warning .assert_called_with ("No environment passed in" )
0 commit comments