Skip to content

Commit eb5b4f9

Browse files
committed
More stringent checks on the registered database results
1 parent 6047bd2 commit eb5b4f9

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

tests/workflows/fib/test_register_milling_progress.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from pathlib import Path
2+
from typing import Any, cast
23
from unittest.mock import MagicMock
34

5+
import ispyb.sqlalchemy._auto_db_schema as ISPyBDB
46
from pytest_mock import MockerFixture
7+
from sqlalchemy import select as sa_select
58
from sqlalchemy.orm import Session as SQLAlchemySession
69
from sqlmodel import Session as SQLModelSession, select as sm_select
710

@@ -401,3 +404,64 @@ def test_run_with_db(
401404
murfey_db=murfey_db_session,
402405
)
403406
assert result.get("success", False)
407+
408+
# There should be a DataCollectionGroup entry in Murfey
409+
dcg_murfey = murfey_db_session.exec(
410+
sm_select(MurfeyDB.DataCollectionGroup)
411+
.where(MurfeyDB.DataCollectionGroup.session_id == session_id)
412+
.where(
413+
MurfeyDB.DataCollectionGroup.tag == f"{site_info['project_name']}--slot_1"
414+
)
415+
).one_or_none()
416+
assert dcg_murfey is not None
417+
418+
# There should be a DataCollectionGroup entry in ISPyB
419+
dcg_ispyb = ispyb_db_session.execute(
420+
sa_select(ISPyBDB.DataCollectionGroup).where(
421+
ISPyBDB.DataCollectionGroup.dataCollectionGroupId == dcg_murfey.id
422+
)
423+
).scalar_one_or_none()
424+
assert dcg_ispyb is not None
425+
426+
# There should be an Atlas in ISPyB
427+
atlas_ispyb = ispyb_db_session.execute(
428+
sa_select(ISPyBDB.Atlas).where(
429+
ISPyBDB.Atlas.dataCollectionGroupId == dcg_ispyb.dataCollectionGroupId
430+
)
431+
).scalar_one_or_none()
432+
assert atlas_ispyb is not None
433+
434+
# There should be one GridSquare entry in ISPyB per lamella site tested
435+
gs_ispyb_rows = (
436+
ispyb_db_session.execute(
437+
sa_select(ISPyBDB.GridSquare).where(
438+
ISPyBDB.GridSquare.atlasId == atlas_ispyb.atlasId
439+
)
440+
)
441+
.scalars()
442+
.all()
443+
)
444+
assert len(gs_ispyb_rows) >= 1
445+
gs_ispyb = gs_ispyb_rows[0]
446+
447+
steps = cast(dict[str, Any], site_info["steps"])
448+
449+
# There should be one MillingStep entry in ISPyB for each step in the message
450+
milling_step_ispyb_rows = (
451+
ispyb_db_session.execute(
452+
sa_select(ISPyBDB.MillingStep).where(
453+
ISPyBDB.MillingStep.gridSquareId == gs_ispyb.gridSquareId
454+
)
455+
)
456+
.scalars()
457+
.all()
458+
)
459+
assert len(milling_step_ispyb_rows) == len(steps.keys())
460+
461+
# There should be the same thing in Murfey
462+
milling_step_murfey_rows = murfey_db_session.exec(
463+
sm_select(MurfeyDB.MillingStep).where(
464+
MurfeyDB.MillingStep.grid_square_id == gs_ispyb.gridSquareId
465+
)
466+
).all()
467+
assert len(milling_step_murfey_rows) == len(steps.keys())

0 commit comments

Comments
 (0)