Skip to content

Commit 7c7cce2

Browse files
committed
Mock both the return value and the context-managed return value of 'ISPyBSession'
1 parent 6ca8dd5 commit 7c7cce2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/workflows/clem/test_register_preprocessing_results.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,28 +189,28 @@ def test_run_with_db(
189189
mock_get_security_config.return_value = mock_security_config
190190

191191
mock_ispyb_session_factory = MagicMock(return_value=ispyb_db_session)
192-
mock_ispyb_session_factory.__enter__.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
193194
# mock_ispyb_sessionmaker = mocker.patch(
194195
mocker.patch(
195196
"murfey.server.ispyb.sessionmaker", return_value=mock_ispyb_session_factory
196197
)
198+
# mocker.patch(
199+
# "murfey.server.ispyb.ISPyBSession",
200+
# return_value=ispyb_db_session,
201+
# )
197202

198203
# Mock the ISPYB connection when registering data collection group
199204
mocker.patch(
200205
"murfey.workflows.register_data_collection_group.ISPyBSession",
201206
return_value=ispyb_db_session,
202207
)
203-
mocker.patch(
204-
"murfey.server.ispyb.ISPyBSession",
205-
return_value=ispyb_db_session,
206-
)
207208

208209
# Mock out the machine config used in the helper sanitisation function
209210
mock_get_machine_config = mocker.patch("murfey.workflows.clem.get_machine_config")
210211
mock_machine_config = MagicMock()
211212
mock_machine_config.rsync_basepath = rsync_basepath
212213
mock_get_machine_config.return_value = {
213-
# "": mock_machine_config,
214214
ExampleVisit.instrument_name: mock_machine_config,
215215
}
216216

0 commit comments

Comments
 (0)