Skip to content

Commit

Permalink
Fix wrong assertion methods in test_celery_executor (apache#37914)
Browse files Browse the repository at this point in the history
* fix test

* remove comments
  • Loading branch information
romsharon98 authored Mar 6, 2024
1 parent 29acfb1 commit 244bbd5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/providers/celery/executors/test_celery_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _prepare_app(broker_url=None, execute=None):
test_config.update({"broker_url": broker_url})
test_app = Celery(broker_url, config_source=test_config)
test_execute = test_app.task(execute)
patch_app = mock.patch("airflow.providers.celery.executors.celery_executor.app", test_app)
patch_app = mock.patch("airflow.providers.celery.executors.celery_executor_utils.app", test_app)
patch_execute = mock.patch(
"airflow.providers.celery.executors.celery_executor_utils.execute_command", test_execute
)
Expand Down Expand Up @@ -250,15 +250,14 @@ def test_cleanup_stuck_queued_tasks(self, mock_fail):
tis = [ti]
with _prepare_app() as app:
app.control.revoke = mock.MagicMock()

executor = celery_executor.CeleryExecutor()
executor.job_id = 1
executor.running = {ti.key}
executor.tasks = {ti.key: AsyncResult("231")}
executor.cleanup_stuck_queued_tasks(tis)
executor.sync()
assert executor.tasks == {}
assert app.control.revoke.called_with("231") # noqa: PGH005 (fixme: called 0 times)
app.control.revoke.assert_called_once_with("231")
mock_fail.assert_called_once()

@conf_vars({("celery", "result_backend_sqlalchemy_engine_options"): '{"pool_recycle": 1800}'})
Expand Down

0 comments on commit 244bbd5

Please sign in to comment.