Skip to content

Commit 7917b40

Browse files
committed
Mock the ISPyBSession object directly
1 parent 31b26f4 commit 7917b40

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

tests/workflows/clem/test_register_preprocessing_results.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,22 @@ def test_run_with_db(
185185
# Mock the ISPyB connection where the TransportManager class is located
186186
mock_security_config = MagicMock()
187187
mock_security_config.ispyb_credentials = mock_ispyb_credentials
188-
mock_get_security_config = mocker.patch("murfey.server.ispyb.get_security_config")
189-
mock_get_security_config.return_value = mock_security_config
190-
191-
mock_ispyb_session_factory = MagicMock(return_value=ispyb_db_session)
192-
mock_ispyb_session_factory.return_value = ispyb_db_session
193-
# mock_ispyb_session_factory.return_value.__enter__.return_value = ispyb_db_session
194-
# mock_ispyb_sessionmaker = mocker.patch(
195188
mocker.patch(
196-
"murfey.server.ispyb.sessionmaker", return_value=mock_ispyb_session_factory
189+
"murfey.server.ispyb.get_security_config",
190+
return_value=mock_security_config,
197191
)
192+
193+
# mock_ispyb_session_factory = MagicMock(return_value=ispyb_db_session)
194+
# mock_ispyb_session_factory.return_value = ispyb_db_session
195+
# # mock_ispyb_session_factory.return_value.__enter__.return_value = ispyb_db_session
196+
# # mock_ispyb_sessionmaker = mocker.patch(
198197
# mocker.patch(
199-
# "murfey.server.ispyb.ISPyBSession",
200-
# return_value=ispyb_db_session,
198+
# "murfey.server.ispyb.sessionmaker", return_value=mock_ispyb_session_factory
201199
# )
200+
mocker.patch(
201+
"murfey.server.ispyb.ISPyBSession",
202+
return_value=ispyb_db_session,
203+
)
202204

203205
# Mock the ISPYB connection when registering data collection group
204206
mocker.patch(

0 commit comments

Comments
 (0)