Skip to content

Commit ff3a3ab

Browse files
committed
Updated DB test to check that only one file was registered
1 parent 5e6b5be commit ff3a3ab

1 file changed

Lines changed: 41 additions & 27 deletions

File tree

tests/workflows/fib/test_register_atlas.py

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,10 @@ def test_run_with_db(
291291
visit_dir: Path,
292292
murfey_db_session: Session,
293293
):
294-
test_file = (
295-
visit_dir / "maps/LayersData/Layer/Electron Snapshot/Electron Snapshot.tiff"
294+
test_files = (
295+
visit_dir / "maps/LayersData/Layer/Electron Snapshot/Electron Snapshot.tiff",
296+
visit_dir
297+
/ "maps/LayersData/Layer/Electron Snapshot/Electron Snapshot (2).tiff",
296298
)
297299

298300
# Add a test visit to the database
@@ -310,33 +312,45 @@ def test_run_with_db(
310312
murfey_db_session.commit()
311313

312314
# Mock the metadata returned from the image file
313-
mock_metadata = FIBAtlasMetadata(
314-
visit_name=visit_name,
315-
file=test_file,
316-
voltage=2000,
317-
shift_x=0,
318-
shift_y=0,
319-
len_x=0.003072,
320-
len_y=0.002048,
321-
pos_x=0.003,
322-
pos_y=0.0003,
323-
pos_z=0.01,
324-
rotation=-1.309,
325-
tilt_alpha=0.8,
326-
tilt_beta=0,
327-
pixels_x=3072,
328-
pixels_y=2048,
329-
pixel_size_x=1e-6,
330-
pixel_size_y=1e-6,
331-
)
315+
mock_metadata = [
316+
FIBAtlasMetadata(
317+
visit_name=visit_name,
318+
file=test_file,
319+
voltage=2000,
320+
shift_x=0,
321+
shift_y=0,
322+
len_x=0.003072,
323+
len_y=0.002048,
324+
pos_x=0.003,
325+
pos_y=0.0003,
326+
pos_z=0.01,
327+
rotation=-1.309,
328+
tilt_alpha=0.8,
329+
tilt_beta=0,
330+
pixels_x=3072,
331+
pixels_y=2048,
332+
pixel_size_x=1e-6,
333+
pixel_size_y=1e-6,
334+
)
335+
for test_file in test_files
336+
]
332337
mocker.patch(
333338
"murfey.workflows.fib.register_atlas._parse_metadata",
334-
return_value=mock_metadata,
339+
side_effect=mock_metadata,
335340
)
336341

337342
# Run the function and check that it's run through to completion
338-
assert run(
339-
session_id=session_id,
340-
file=test_file,
341-
murfey_db=murfey_db_session,
342-
)
343+
for test_file in test_files:
344+
run(
345+
session_id=session_id,
346+
file=test_file,
347+
murfey_db=murfey_db_session,
348+
)
349+
search_results = murfey_db_session.exec(
350+
select(MurfeyDB.ImagingSite).where(
351+
MurfeyDB.ImagingSite.session_id == session_id
352+
)
353+
).all()
354+
355+
assert len(search_results) == 1
356+
assert search_results[0].image_path == str(mock_metadata[-1].file)

0 commit comments

Comments
 (0)