@@ -190,15 +190,23 @@ def test_handle_failed_posts(tmp_path):
190190@mock .patch ("murfey.cli.repost_failed_calls.dlq_purge" )
191191@mock .patch ("murfey.cli.repost_failed_calls.handle_failed_posts" )
192192@mock .patch ("murfey.cli.repost_failed_calls.handle_dlq_messages" )
193- @mock .patch ("murfey.cli.repost_failed_calls.get_murfey_db_session" )
193+ @mock .patch ("murfey.cli.repost_failed_calls.url" )
194+ @mock .patch ("murfey.cli.repost_failed_calls.create_engine" )
195+ @mock .patch ("murfey.cli.repost_failed_calls.Session" )
194196def test_run_repost_failed_calls (
195- mock_db ,
197+ mock_db_session ,
198+ mock_db_engine ,
199+ mock_db_url ,
196200 mock_reinject ,
197201 mock_repost ,
198202 mock_purge ,
199203 mock_security_configuration ,
200204):
201- mock_db .return_value = "db"
205+ mock_session = mock .MagicMock ()
206+
207+ mock_db_url .return_value = "db_url"
208+ mock_db_engine .return_value = "db_engine"
209+ mock_db_session .return_value = mock_session
202210 mock_purge .return_value = ["/path/to/msg1" ]
203211
204212 config_file = mock_security_configuration
@@ -215,14 +223,16 @@ def test_run_repost_failed_calls(
215223 repost_failed_calls .run ()
216224
217225 security_config_class = security_from_file (config_file )
218- mock_db .assert_called_with (security_config_class )
226+ mock_db_url .assert_called_with (security_config_class )
227+ mock_db_engine .assert_called_with ("db_url" )
228+ mock_db_session .assert_called_with ("db_engine" )
219229
220230 mock_purge .assert_called_once_with (
221231 Path ("DLQ_dir" ),
222232 "murfey_feedback" ,
223233 Path (security_config_dict ["rabbitmq_credentials" ]),
224234 )
225- mock_repost .assert_called_once_with (["/path/to/msg1" ], "db" )
235+ mock_repost .assert_called_once_with (["/path/to/msg1" ], mock_session . __enter__ () )
226236 mock_reinject .assert_called_once_with (
227237 ["/path/to/msg1" ], Path (security_config_dict ["rabbitmq_credentials" ])
228238 )
0 commit comments