33import pytest
44
55from murfey .client .analyser import Analyser
6- from murfey .client .contexts .atlas import AtlasContext
7- from murfey .client .contexts .clem import CLEMContext
8- from murfey .client .contexts .fib import FIBContext
96from murfey .client .contexts .spa import SPAContext
10- from murfey .client .contexts .spa_metadata import SPAMetadataContext
11- from murfey .client .contexts .sxt import SXTContext
127from murfey .client .contexts .tomo import TomographyContext
13- from murfey .client .contexts .tomo_metadata import TomographyMetadataContext
148from murfey .util .models import ProcessingParametersSPA , ProcessingParametersTomo
159
16- example_files = [
17- # Tomography
18- ["visit/Position_1_001_0.0_20250715_012434_fractions.tiff" , TomographyContext ],
19- ["visit/Position_1_2_002_3.0_20250715_012434_Fractions.mrc" , TomographyContext ],
20- ["visit/Position_1_2_003_6.0_20250715_012434_EER.eer" , TomographyContext ],
21- ["visit/name1_004_9.0_20250715_012434_fractions.tiff" , TomographyContext ],
22- ["visit/Position_1_[30.0].tiff" , TomographyContext ],
23- ["visit/Position_1.mdoc" , TomographyContext ],
24- ["visit/name1_2.mdoc" , TomographyContext ],
25- # Tomography metadata
26- ["visit/Session.dm" , TomographyMetadataContext ],
27- ["visit/SearchMaps/SearchMap.xml" , TomographyMetadataContext ],
28- ["visit/Batch/BatchPositionsList.xml" , TomographyMetadataContext ],
29- ["visit/Thumbnails/file.mrc" , TomographyMetadataContext ],
30- # SPA
31- ["visit/FoilHole_01234_fractions.tiff" , SPAContext ],
32- ["visit/FoilHole_01234_EER.eer" , SPAContext ],
33- # SPA metadata
34- ["atlas/atlas.mrc" , AtlasContext ],
35- ["visit/EpuSession.dm" , SPAMetadataContext ],
36- ["visit/Metadata/GridSquare.dm" , SPAMetadataContext ],
37- # CLEM LIF file
38- ["visit/images/test_file.lif" , CLEMContext ],
39- # CLEM TIFF files
40- [
10+ example_files = {
11+ "CLEMContext" : [
12+ # CLEM LIF file
13+ "visit/images/test_file.lif" ,
14+ # CLEM TIFF files
4115 "visit/images/2024_03_14_12_34_56--Project001/grid1/Position 12--Z02--C01.tif" ,
42- CLEMContext ,
43- ],
44- [
4516 "visit/images/2024_03_14_12_34_56--Project001/grid1/Position 12_Lng_LVCC--Z02--C01.tif" ,
46- CLEMContext ,
47- ],
48- [
4917 "visit/images/2024_03_14_12_34_56--Project001/grid1/Series001--Z00--C00.tif" ,
50- CLEMContext ,
51- ],
52- [
5318 "visit/images/2024_03_14_12_34_56--Project001/grid1/Series001_Lng_LVCC--Z00--C00.tif" ,
54- CLEMContext ,
55- ],
56- # CLEM TIFF file accompanying metadata
57- [
19+ # CLEM TIFF file accompanying metadata
5820 "visit/images/2024_03_14_12_34_56--Project001/grid1/Metadata/Position 12.xlif" ,
59- CLEMContext ,
60- ],
61- [
6221 "visit/images/2024_03_14_12_34_56--Project001/grid1/Metadata/Position 12_Lng_LVCC.xlif" ,
63- CLEMContext ,
64- ],
65- [
6622 "visit/images/2024_03_14_12_34_56--Project001/grid1/Position 12/Metadata/Position 12_histo.xlif" ,
67- CLEMContext ,
68- ],
69- [
7023 "visit/images/2024_03_14_12_34_56--Project001/grid1/Position 12/Metadata/Position 12_Lng_LVCC_histo.xlif" ,
71- CLEMContext ,
72- ],
73- [
7424 "visit/images/2024_03_14_12_34_56--Project001/grid1/Metadata/Series001.xlif" ,
75- CLEMContext ,
76- ],
77- [
7825 "visit/images/2024_03_14_12_34_56--Project001/grid1/Metadata/Series001_Lng_LVCC.xlif" ,
79- CLEMContext ,
8026 ],
81- # FIB Autotem files
82- [ "visit/autotem/visit/ProjectData.dat" , FIBContext ],
83- [ "visit/autotem/visit/Sites/Lamella/SetupImages/Preparation.tif" , FIBContext ] ,
84- [
27+ "FIBContext" : [
28+ # FIB Autotem files
29+ "visit/autotem/visit/ProjectData.dat" ,
30+ "visit/autotem/visit/Sites/Lamella/SetupImages/Preparation.tif" ,
8531 "visit/autotem/visit/Sites/Lamella (2)//DCImages/DCM_2026-03-09-23-45-40.926/2026-03-09-23-48-43-Finer-Milling-dc_rescan-image-.png" ,
86- FIBContext ,
87- ],
88- # FIB Maps files
89- ["visit/maps/visit/EMproject.emxml" , FIBContext ],
90- [
32+ # FIB Maps files
33+ "visit/maps/visit/EMproject.emxml" ,
9134 "visit/maps/visit/LayersData/Layer/Electron Snapshot/Electron Snapshot.tiff" ,
92- FIBContext ,
93- ],
94- [
9535 "visit/maps/visit/LayersData/Layer/Electron Snapshot (2)/Electron Snapshot (2).tiff" ,
96- FIBContext ,
9736 ],
98- # Soft x-ray tomography
99- ["visit/tomo__tag_ROI10_area1_angle-60to60@1.5_1sec_251p.txrm" , SXTContext ],
100- ["visit/X-ray_mosaic_ROI2.xrm" , SXTContext ],
101- ]
37+ "SXTContext" : [
38+ "visit/tomo__tag_ROI10_area1_angle-60to60@1.5_1sec_251p.txrm" ,
39+ "visit/X-ray_mosaic_ROI2.xrm" ,
40+ ],
41+ "AtlasContext" : [
42+ "atlas/atlas.mrc" ,
43+ ],
44+ "TomographyContext" : [
45+ "visit/Position_1_001_0.0_20250715_012434_fractions.tiff" ,
46+ "visit/Position_1_2_002_3.0_20250715_012434_Fractions.mrc" ,
47+ "visit/Position_1_2_003_6.0_20250715_012434_EER.eer" ,
48+ "visit/name1_004_9.0_20250715_012434_fractions.tiff" ,
49+ "visit/Position_1_[30.0].tiff" ,
50+ "visit/Position_1.mdoc" ,
51+ "visit/name1_2.mdoc" ,
52+ ],
53+ "TomographyMetadataContext" : [
54+ "visit/Session.dm" ,
55+ "visit/SearchMaps/SearchMap.xml" ,
56+ "visit/Batch/BatchPositionsList.xml" ,
57+ "visit/Thumbnails/file.mrc" ,
58+ ],
59+ "SPAContext" : [
60+ "visit/FoilHole_01234_fractions.tiff" ,
61+ "visit/FoilHole_01234_EER.eer" ,
62+ ],
63+ "SPAMetadataContext" : [
64+ "visit/EpuSession.dm" ,
65+ "visit/Metadata/GridSquare.dm" ,
66+ ],
67+ }
10268
10369
104- @pytest .mark .parametrize ("file_and_context" , example_files )
70+ @pytest .mark .parametrize (
71+ "file_and_context" ,
72+ [
73+ [file , context ]
74+ for context , file_list in example_files .items ()
75+ for file in file_list
76+ ],
77+ )
10578def test_find_context (file_and_context , tmp_path ):
10679 # Unpack parametrised variables
10780 file_name , context = file_and_context
@@ -111,7 +84,7 @@ def test_find_context(file_and_context, tmp_path):
11184
11285 # Check that the results are as expected
11386 assert analyser ._find_context (tmp_path / file_name )
114- assert isinstance ( analyser ._context , context )
87+ assert analyser ._context is not None and context in str ( analyser . _context )
11588
11689 # Checks for the specific workflow contexts
11790 if isinstance (analyser ._context , TomographyContext ):
0 commit comments