@@ -66,26 +66,26 @@ def mock_config_file(tmp_path: Path):
6666
6767@pytest .mark .parametrize (
6868 "test_params" ,
69- ( # Use recwrap | Use ISPyB | Ref type | Mov type
70- (True , True , "Tomography" , "FIB" ),
71- (False , True , "Tomography" , "FIB" ),
72- (True , False , "Tomography" , "Single Particle" ),
73- (False , False , "Tomography" , "Single Particle" ),
74- (True , True , "Tomography" , "CLEM" ),
75- (False , True , "Tomography" , "CLEM" ),
76- (True , True , "Lamella Tomography" , "FIB" ),
77- (False , True , "Lamella Tomography" , "FIB" ),
69+ ( # Use recwrap | Use ISPyB | Ref type | Mov type | Alignment successful
70+ (True , True , "Tomography" , "FIB" , True ),
71+ (False , True , "Tomography" , "FIB" , False ),
72+ (True , False , "Tomography" , "Single Particle" , True ),
73+ (False , False , "Tomography" , "Single Particle" , False ),
74+ (True , True , "Tomography" , "CLEM" , True ),
75+ (False , True , "Tomography" , "CLEM" , False ),
76+ (True , True , "Lamella Tomography" , "FIB" , True ),
77+ (False , True , "Lamella Tomography" , "FIB" , False ),
7878 ),
7979)
8080def test_align_images_service (
8181 mocker : MockerFixture ,
8282 tmp_path : Path ,
8383 mock_config_file : Path ,
8484 offline_transport : OfflineTransport ,
85- test_params : tuple [bool , bool , str , str ],
85+ test_params : tuple [bool , bool , str , str , bool ],
8686):
8787 # Set up the message parameters
88- use_recwrap , use_ispyb , ref_type , mov_type = test_params
88+ use_recwrap , use_ispyb , ref_type , mov_type , alignment_successful = test_params
8989
9090 # Set up reference image and moving image parameters
9191 id_ref = 1
@@ -178,10 +178,18 @@ def test_align_images_service(
178178 ],
179179 )
180180
181+ # Mock the '_reject_message' function
182+ mock_reject = mocker .patch (
183+ "cryoemservices.services.common_service.CommonService._reject_message"
184+ )
185+
181186 # Mock the '_handle_fib_tomo_case' class function
182187 mock_handle_fib_tomo = mocker .patch (
183188 "cryoemservices.services.correlative_align_images.AlignImagesService._handle_fib_tomo_case"
184189 )
190+ mock_handle_fib_tomo .return_value = {
191+ "transform" : np .ones ((3 , 3 ), dtype = np .float32 ) if alignment_successful else None
192+ }
185193
186194 # Set up and run the service
187195 service = AlignImagesService (
@@ -229,10 +237,21 @@ def test_align_images_service(
229237 save_dir ,
230238 params ,
231239 )
240+ if alignment_successful :
241+ service .log .info .assert_called_with (
242+ "Successfully aligned FIB atlas to tomography atlas"
243+ )
244+ mock_reject .assert_not_called ()
245+ else :
246+ service .log .error .assert_called_with (
247+ "Could not align FIB atlas to tomography atlas"
248+ )
249+ mock_reject .assert_called ()
232250 case _:
233251 service .log .info .assert_called_with (
234252 "No image alignment algorithm implemented for this case yet"
235253 )
254+ mock_reject .assert_not_called ()
236255
237256
238257def test_handle_fib_tomo_case (
0 commit comments