@@ -372,8 +372,10 @@ def test_analyse_generic(
372372 assert mock_post_transfer .call_count == len (test_files )
373373
374374
375+ @pytest .mark .parametrize ("has_extension" , [True , False ])
375376def test_analyse_spa (
376377 mocker : MockerFixture ,
378+ has_extension : bool ,
377379 tmp_path : Path ,
378380):
379381 test_files = [
@@ -384,24 +386,46 @@ def test_analyse_spa(
384386 ]
385387
386388 # Set up mocks and spies
389+ mock_metadata = {
390+ "dummy" : "dummy" ,
391+ }
392+ if has_extension :
393+ mock_metadata ["file_extension" ] = ".tiff"
394+
387395 mock_post_transfer = mocker .patch .object (Analyser , "post_transfer" )
396+ mock_gather_metadata = mocker .patch (
397+ "murfey.client.contexts.spa.SPAContext.gather_metadata" ,
398+ return_value = mock_metadata ,
399+ )
400+ mock_notify = mocker .patch .object (Analyser , "notify" )
388401 spy_find_context = mocker .spy (Analyser , "_find_context" )
389402 spy_find_extension = mocker .spy (Analyser , "_find_extension" )
390403
391404 # Initialise the Analyser
392- analyser = Analyser (tmp_path , "" , force_mdoc_metadata = True )
405+ analyser = Analyser (tmp_path , "" )
393406 for file in test_files :
394407 analyser ._analyse (tmp_path / file )
395408
396409 assert spy_find_context .call_count == 1
397410 assert analyser ._context is not None and analyser ._context .name == "SPAContext"
398- assert spy_find_extension .call_count > 0
399- assert analyser ._extension in (".eer" , ".tiff" )
400411 mock_post_transfer .assert_called ()
401412
413+ assert spy_find_extension .call_count > 0
414+ assert analyser ._extension == ".tiff"
415+ mock_gather_metadata .assert_called ()
416+ mock_notify .assert_called_with (
417+ {
418+ "dummy" : "dummy" ,
419+ "file_extension" : analyser ._extension ,
420+ "acquisition_software" : analyser ._context ._acquisition_software ,
421+ }
422+ )
423+
402424
425+ @pytest .mark .parametrize ("has_extension" , [True , False ])
403426def test_analyse_tomo (
404427 mocker : MockerFixture ,
428+ has_extension : bool ,
405429 tmp_path : Path ,
406430):
407431 test_files = [
@@ -412,19 +436,39 @@ def test_analyse_tomo(
412436 ]
413437
414438 # Set up mocks and spies
439+ mock_metadata = {
440+ "dummy" : "dummy" ,
441+ }
442+ if has_extension :
443+ mock_metadata ["file_extension" ] = ".tiff"
444+
415445 mock_post_transfer = mocker .patch .object (Analyser , "post_transfer" )
416446 mock_gather_metadata = mocker .patch (
417- "murfey.client.contexts.tomo.TomographyContext.gather_metadata"
447+ "murfey.client.contexts.tomo.TomographyContext.gather_metadata" ,
448+ return_value = mock_metadata ,
418449 )
419- mock_gather_metadata . return_value = { "dummy" : "dummy" }
450+ mock_notify = mocker . patch . object ( Analyser , "notify" )
420451 spy_find_context = mocker .spy (Analyser , "_find_context" )
421452 spy_find_extension = mocker .spy (Analyser , "_find_extension" )
422453
423454 # Initialise the Analyser
424- analyser = Analyser (tmp_path , "" , force_mdoc_metadata = True )
455+ analyser = Analyser (tmp_path , "" )
425456 for file in test_files :
426457 analyser ._analyse (tmp_path / file )
427458
428459 assert spy_find_context .call_count == 1
429- assert spy_find_extension .call_count > 0
460+ assert (
461+ analyser ._context is not None and analyser ._context .name == "TomographyContext"
462+ )
430463 mock_post_transfer .assert_called ()
464+
465+ assert spy_find_extension .call_count > 0
466+ assert analyser ._extension == ".tiff"
467+ mock_gather_metadata .assert_called ()
468+ mock_notify .assert_called_with (
469+ {
470+ "dummy" : "dummy" ,
471+ "file_extension" : analyser ._extension ,
472+ "acquisition_software" : analyser ._context ._acquisition_software ,
473+ }
474+ )
0 commit comments