This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 2f146b95a0b Fix Celery worker test mocking real broker after 
hostname-check refactor (#65842)
2f146b95a0b is described below

commit 2f146b95a0b8cec55bff29113c197fbab178be2b
Author: Jarek Potiuk <[email protected]>
AuthorDate: Sat Apr 25 19:53:04 2026 +0200

    Fix Celery worker test mocking real broker after hostname-check refactor 
(#65842)
    
    `TestWorkerStart::test_worker_started_with_required_arguments` passes
    `--celery-hostname`, which now hits the throwaway `Celery()` app
    introduced in #65826. Without mocking that constructor, the test tried
    to open a real broker connection and failed with `Connection refused`
    in CI. Patch `Celery` (and `kombu.pools.reset`) the same way the
    sibling `TestWorkerDuplicateHostnameCheck` tests do.
---
 providers/celery/tests/unit/celery/cli/test_celery_command.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/providers/celery/tests/unit/celery/cli/test_celery_command.py 
b/providers/celery/tests/unit/celery/cli/test_celery_command.py
index a14cadfee15..99a9506f3d6 100644
--- a/providers/celery/tests/unit/celery/cli/test_celery_command.py
+++ b/providers/celery/tests/unit/celery/cli/test_celery_command.py
@@ -139,11 +139,15 @@ class TestWorkerStart:
             importlib.reload(cli_parser)
             cls.parser = cli_parser.get_parser()
 
+    
@mock.patch("airflow.providers.celery.cli.celery_command.kombu.pools.reset")
+    @mock.patch("airflow.providers.celery.cli.celery_command.Celery")
     @mock.patch("airflow.providers.celery.cli.celery_command.setup_locations")
     @mock.patch("airflow.providers.celery.cli.celery_command.Process")
     @mock.patch("airflow.providers.celery.executors.celery_executor.app")
     @conf_vars({("celery", "pool"): "prefork"})
-    def test_worker_started_with_required_arguments(self, mock_celery_app, 
mock_popen, mock_locations):
+    def test_worker_started_with_required_arguments(
+        self, mock_celery_app, mock_popen, mock_locations, mock_celery_cls, 
mock_pools_reset
+    ):
         pid_file = "pid_file"
         mock_locations.return_value = (pid_file, None, None, None)
         concurrency = "1"

Reply via email to