Skip to content

Commit 569c670

Browse files
committed
Try mocking out the count for faster tests
1 parent 15df9a7 commit 569c670

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/workflows/tomo/test_tomo_picking.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,13 @@ def test_picked_tomogram_not_run_class2d(
152152

153153
@mock.patch("murfey.workflows.tomo.picking._transport_object")
154154
@mock.patch("murfey.workflows.tomo.picking._ids_tomo_classification")
155+
@mock.patch("murfey.workflows.tomo.picking.sqlalchemy.func")
155156
def test_picked_tomogram_run_class2d_with_diameter(
156-
mock_ids, mock_transport, murfey_db_session: Session, tmp_path
157+
mock_func, mock_ids, mock_transport, murfey_db_session: Session, tmp_path
157158
):
158159
"""Run the picker feedback with a pre-determined particle diameter"""
159160
mock_transport.feedback_queue = "murfey_feedback"
161+
mock_func.count.return_value = 10001
160162

161163
# Insert table dependencies
162164
dcg_id, dc_id, pj_id = set_up_picking_db(murfey_db_session)
@@ -173,7 +175,7 @@ def test_picked_tomogram_run_class2d_with_diameter(
173175
"particle_diameter": 200,
174176
},
175177
)
176-
for particle in range(10001):
178+
for particle in range(10):
177179
get_or_create_db_entry(
178180
murfey_db_session,
179181
ParticleSizes,
@@ -199,6 +201,7 @@ def test_picked_tomogram_run_class2d_with_diameter(
199201
picking._register_picked_tomogram_use_diameter(message, murfey_db_session)
200202

201203
mock_ids.assert_called_once_with(0, "em-tomo-class2d", murfey_db_session)
204+
mock_func.count.assert_called_once()
202205

203206
tomograms_db = murfey_db_session.exec(
204207
select(TomogramPicks).where(TomogramPicks.pj_id == 1)
@@ -236,11 +239,13 @@ def test_picked_tomogram_run_class2d_with_diameter(
236239

237240
@mock.patch("murfey.workflows.tomo.picking._transport_object")
238241
@mock.patch("murfey.workflows.tomo.picking._ids_tomo_classification")
242+
@mock.patch("murfey.workflows.tomo.picking.sqlalchemy.func")
239243
def test_picked_tomogram_run_class2d_estimate_diameter(
240-
mock_ids, mock_transport, murfey_db_session: Session, tmp_path
244+
mock_func, mock_ids, mock_transport, murfey_db_session: Session, tmp_path
241245
):
242246
"""Run the picker feedback for Class2D, including diameter estimation"""
243247
mock_transport.feedback_queue = "murfey_feedback"
248+
mock_func.count.return_value = 10001
244249

245250
# Insert table dependencies
246251
dcg_id, dc_id, pj_id = set_up_picking_db(murfey_db_session)
@@ -257,7 +262,7 @@ def test_picked_tomogram_run_class2d_estimate_diameter(
257262
"particle_diameter": None,
258263
},
259264
)
260-
for particle in range(10001):
265+
for particle in range(10):
261266
get_or_create_db_entry(
262267
murfey_db_session,
263268
ParticleSizes,
@@ -295,10 +300,10 @@ def test_picked_tomogram_run_class2d_estimate_diameter(
295300
picking._register_picked_tomogram_use_diameter(message, murfey_db_session)
296301

297302
mock_ids.assert_called_once_with(0, "em-tomo-class2d", murfey_db_session)
303+
mock_func.count.assert_called_once()
298304

299305
# Two mock calls - one flushed tomogram and one new
300306
assert mock_transport.send.call_count == 2
301-
print(mock_transport.send.mock_calls)
302307
mock_transport.send.assert_any_call(
303308
"processing_recipe",
304309
{

0 commit comments

Comments
 (0)