22
33from sqlmodel import Session , select
44
5- from murfey .server .api .workflow import register_dc_group
5+ from murfey .server .api .workflow import DCGroupParameters , register_dc_group
66from murfey .util .db import DataCollectionGroup , SearchMap
77from tests .conftest import ExampleVisit
88
@@ -13,13 +13,13 @@ def test_register_dc_group_new_dcg(mock_transport, murfey_db_session: Session):
1313 mock_transport .feedback_queue = "mock_feedback_queue"
1414
1515 # Request new dcg registration
16- dcg_params = {
17- " experiment_type_id" : 44 ,
18- " tag" : "atlas_tag" ,
19- " atlas" : "/path/to/Atlas_1.jpg" ,
20- " sample" : 1 ,
21- " atlas_pixel_size" : 1e-5 ,
22- }
16+ dcg_params = DCGroupParameters (
17+ experiment_type_id = 44 ,
18+ tag = "atlas_tag" ,
19+ atlas = "/path/to/Atlas_1.jpg" ,
20+ sample = 10 ,
21+ atlas_pixel_size = 1e-5 ,
22+ )
2323 register_dc_group (
2424 visit_name = "cm12345-6" ,
2525 session_id = ExampleVisit .murfey_session_id ,
@@ -33,12 +33,12 @@ def test_register_dc_group_new_dcg(mock_transport, murfey_db_session: Session):
3333 {
3434 "register" : "data_collection_group" ,
3535 "start_time" : mock .ANY ,
36- "experiment_type_id" : dcg_params [ "experiment_type_id" ] ,
37- "tag" : dcg_params [ "tag" ] ,
36+ "experiment_type_id" : 44 ,
37+ "tag" : "atlas_tag" ,
3838 "session_id" : ExampleVisit .murfey_session_id ,
39- "atlas" : dcg_params [ "atlas" ] ,
40- "sample" : dcg_params [ "sample" ] ,
41- "atlas_pixel_size" : dcg_params [ "atlas_pixel_size" ] ,
39+ "atlas" : "/path/to/Atlas_1.jpg" ,
40+ "sample" : 10 ,
41+ "atlas_pixel_size" : 1e-5 ,
4242 "microscope" : ExampleVisit .instrument_name ,
4343 "proposal_code" : ExampleVisit .proposal_code ,
4444 "proposal_number" : ExampleVisit .proposal_number ,
@@ -64,20 +64,20 @@ def test_register_dc_group_atlas_to_processing(
6464 tag = "atlas_tag" ,
6565 atlas_id = 90 ,
6666 atlas_pixel_size = 1e-5 ,
67- sample = 1 ,
67+ sample = 10 ,
6868 atlas = "/path/to/Atlas_1.jpg" ,
6969 )
7070 murfey_db_session .add (dcg )
7171 murfey_db_session .commit ()
7272
7373 # Request new dcg registration with processing experiment type and tag
74- dcg_params = {
75- " experiment_type_id" : 36 ,
76- " tag" : "processing_tag" ,
77- " atlas" : "/path/to/Atlas_1.jpg" ,
78- " sample" : 1 ,
79- " atlas_pixel_size" : 1e-5 ,
80- }
74+ dcg_params = DCGroupParameters (
75+ experiment_type_id = 36 ,
76+ tag = "processing_tag" ,
77+ atlas = "/path/to/Atlas_1.jpg" ,
78+ sample = 10 ,
79+ atlas_pixel_size = 1e-5 ,
80+ )
8181 register_dc_group (
8282 visit_name = "cm12345-6" ,
8383 session_id = ExampleVisit .murfey_session_id ,
@@ -90,16 +90,16 @@ def test_register_dc_group_atlas_to_processing(
9090 "mock_feedback_queue" ,
9191 {
9292 "register" : "experiment_type_update" ,
93- "experiment_type_id" : dcg_params [ "experiment_type_id" ] ,
94- "dcgid" : dcg . id ,
93+ "experiment_type_id" : 36 ,
94+ "dcgid" : 1 ,
9595 },
9696 )
9797
9898 # Check that the tag of the data collection group was updated
9999 new_dcg = murfey_db_session .exec (
100- select (DataCollectionGroup ).where (DataCollectionGroup .id == dcg . id )
100+ select (DataCollectionGroup ).where (DataCollectionGroup .id == 1 )
101101 ).one ()
102- assert new_dcg .tag == dcg_params [ "tag" ]
102+ assert new_dcg .tag == "preprocessing_tag"
103103
104104
105105@mock .patch ("murfey.server.api.workflow._transport_object" )
@@ -126,13 +126,13 @@ def test_register_dc_group_processing_to_atlas(
126126 murfey_db_session .commit ()
127127
128128 # Request new dcg registration with atlas experiment type and tag
129- dcg_params = {
130- " experiment_type_id" : 44 ,
131- " tag" : "atlas_tag" ,
132- " atlas" : "/path/to/Atlas_2.jpg" ,
133- " sample" : 1 ,
134- " atlas_pixel_size" : 1e-4 ,
135- }
129+ dcg_params = DCGroupParameters (
130+ experiment_type_id = 44 ,
131+ tag = "atlas_tag" ,
132+ atlas = "/path/to/Atlas_2.jpg" ,
133+ sample = 10 ,
134+ atlas_pixel_size = 1e-4 ,
135+ )
136136 register_dc_group (
137137 visit_name = "cm12345-6" ,
138138 session_id = ExampleVisit .murfey_session_id ,
@@ -145,23 +145,23 @@ def test_register_dc_group_processing_to_atlas(
145145 "mock_feedback_queue" ,
146146 {
147147 "register" : "atlas_update" ,
148- "atlas_id" : dcg . atlas_id ,
149- "atlas" : dcg_params [ "atlas" ] ,
150- "sample" : dcg_params [ "sample" ] ,
151- "atlas_pixel_size" : dcg_params [ "atlas_pixel_size" ] ,
152- "dcgid" : dcg . id ,
148+ "atlas_id" : 90 ,
149+ "atlas" : "/path/to/Atlas_2.jpg" ,
150+ "sample" : 10 ,
151+ "atlas_pixel_size" : 1e-4 ,
152+ "dcgid" : 1 ,
153153 "session_id" : ExampleVisit .murfey_session_id ,
154154 },
155155 )
156156
157157 # Check the data collection group atlas was updated
158158 new_dcg = murfey_db_session .exec (
159- select (DataCollectionGroup ).where (DataCollectionGroup .id == dcg . id )
159+ select (DataCollectionGroup ).where (DataCollectionGroup .id == 1 )
160160 ).one ()
161- assert new_dcg .atlas == dcg_params [ "atlas" ]
162- assert new_dcg .atlas_pixel_size == dcg_params [ "atlas_pixel_size" ]
161+ assert new_dcg .atlas == "/path/to/Atlas_2.jpg"
162+ assert new_dcg .atlas_pixel_size == 1e-4
163163 # Check the tag of the data collection group was not updated
164- assert new_dcg .tag != dcg_params [ "tag" ]
164+ assert new_dcg .tag != "atlas_tag"
165165
166166
167167@mock .patch ("murfey.server.api.workflow._transport_object" )
@@ -183,13 +183,13 @@ def test_register_dc_group_new_atlas(mock_transport, murfey_db_session: Session)
183183 murfey_db_session .commit ()
184184
185185 # Request new dcg registration with atlas and exisiting tag
186- dcg_params = {
187- " experiment_type_id" : 36 ,
188- " tag" : "processing_tag" ,
189- " atlas" : "/path/to/Atlas_2.jpg" ,
190- " sample" : 1 ,
191- " atlas_pixel_size" : 1e-4 ,
192- }
186+ dcg_params = DCGroupParameters (
187+ experiment_type_id = 36 ,
188+ tag = "processing_tag" ,
189+ atlas = "/path/to/Atlas_2.jpg" ,
190+ sample = 10 ,
191+ atlas_pixel_size = 1e-4 ,
192+ )
193193 register_dc_group (
194194 visit_name = "cm12345-6" ,
195195 session_id = ExampleVisit .murfey_session_id ,
@@ -203,19 +203,19 @@ def test_register_dc_group_new_atlas(mock_transport, murfey_db_session: Session)
203203 # Check the call to insert the atlas into ispyb
204204 atlas_args = mock_transport .do_insert_atlas .call_args_list
205205 assert len (atlas_args ) == 1
206- assert atlas_args [0 ].dataCollectionGroupId == dcg . id
207- assert atlas_args [0 ].atlasImage == dcg_params [ "atlas" ]
208- assert atlas_args [0 ].pixelSize == dcg_params [ "atlas_pixel_size" ]
209- assert atlas_args [0 ].cassetteSlot == dcg_params [ "sample" ]
206+ assert atlas_args [0 ].dataCollectionGroupId == 1
207+ assert atlas_args [0 ].atlasImage == "/path/to/Atlas_2.jpg"
208+ assert atlas_args [0 ].pixelSize == 1e-4
209+ assert atlas_args [0 ].cassetteSlot == 10
210210
211211 # Check the data collection group atlas was updated
212212 new_dcg = murfey_db_session .exec (
213- select (DataCollectionGroup ).where (DataCollectionGroup .id == dcg . id )
213+ select (DataCollectionGroup ).where (DataCollectionGroup .id == 1 )
214214 ).one ()
215- assert new_dcg .atlas == dcg_params [ "atlas" ]
216- assert new_dcg .sample == dcg_params [ "sample" ]
217- assert new_dcg .atlas_pixel_size == dcg_params [ "atlas_pixel_size" ]
218- assert new_dcg .tag == dcg_params [ "tag" ]
215+ assert new_dcg .atlas == "/path/to/Atlas_2.jpg"
216+ assert new_dcg .sample == 10
217+ assert new_dcg .atlas_pixel_size == 1e-4
218+ assert new_dcg .tag == "atlas_tag"
219219 assert new_dcg .atlas_id == 5
220220
221221
@@ -237,7 +237,7 @@ def test_register_dc_group_new_atlas_with_searchmaps(
237237 tag = "processing_tag" ,
238238 atlas_id = 90 ,
239239 atlas_pixel_size = 1e-5 ,
240- sample = 1 ,
240+ sample = 10 ,
241241 atlas = "/path/to/Atlas_1.jpg" ,
242242 )
243243 murfey_db_session .add (dcg )
@@ -268,13 +268,13 @@ def test_register_dc_group_new_atlas_with_searchmaps(
268268 murfey_db_session .commit ()
269269
270270 # Request new dcg registration with new atlas tag and sample
271- dcg_params = {
272- " experiment_type_id" : 37 ,
273- " tag" : "processing_tag" ,
274- " atlas" : "/path/to/Atlas_2.jpg" ,
275- " sample" : 2 ,
276- " atlas_pixel_size" : 1e-4 ,
277- }
271+ dcg_params = DCGroupParameters (
272+ experiment_type_id = 37 ,
273+ tag = "processing_tag" ,
274+ atlas = "/path/to/Atlas_2.jpg" ,
275+ sample = 12 ,
276+ atlas_pixel_size = 1e-4 ,
277+ )
278278 register_dc_group (
279279 visit_name = "cm12345-6" ,
280280 session_id = ExampleVisit .murfey_session_id ,
@@ -287,11 +287,11 @@ def test_register_dc_group_new_atlas_with_searchmaps(
287287 "mock_feedback_queue" ,
288288 {
289289 "register" : "atlas_update" ,
290- "atlas_id" : dcg . atlas_id ,
291- "atlas" : dcg_params [ "atlas" ] ,
292- "sample" : dcg_params [ "sample" ] ,
293- "atlas_pixel_size" : dcg_params [ "atlas_pixel_size" ] ,
294- "dcgid" : dcg . id ,
290+ "atlas_id" : 90 ,
291+ "atlas" : "/path/to/Atlas_2.jpg" ,
292+ "sample" : 12 ,
293+ "atlas_pixel_size" : 1e-4 ,
294+ "dcgid" : 1 ,
295295 "session_id" : ExampleVisit .murfey_session_id ,
296296 },
297297 )
@@ -300,11 +300,11 @@ def test_register_dc_group_new_atlas_with_searchmaps(
300300 new_dcg = murfey_db_session .exec (
301301 select (DataCollectionGroup ).where (DataCollectionGroup .id == dcg .id )
302302 ).one ()
303- assert new_dcg .atlas == dcg_params [ "atlas" ]
304- assert new_dcg .sample == dcg_params [ "sample" ]
305- assert new_dcg .atlas_pixel_size == dcg_params [ "atlas_pixel_size" ]
306- assert new_dcg .tag == dcg_params [ "tag" ]
307- assert new_dcg .atlas_id == dcg . atlas_id
303+ assert new_dcg .atlas == "/path/to/Atlas_2.jpg"
304+ assert new_dcg .sample == 12
305+ assert new_dcg .atlas_pixel_size == 1e-4
306+ assert new_dcg .tag == "processing_tag"
307+ assert new_dcg .atlas_id == 90
308308
309309 # Check the search map update calls
310310 assert mock_register_search_map .call_count == 2
0 commit comments