| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from unittest.mock import patch |
| 4 |
|
| 5 |
import pytest |
| 6 |
from click.testing import CliRunner |
| 7 |
|
| 8 |
from celery.bin.celery import celery |
| 9 |
|
| 10 |
from .proj import daemon_config as config |
| 11 |
|
| 12 |
|
| 13 |
@pytest.mark.usefixtures('depends_on_current_app') |
| 14 |
@pytest.mark.parametrize("daemon", ["worker", "beat", "events"]) |
| 15 |
def test_daemon_options_from_config(daemon: str, cli_runner: CliRunner): |
| 16 |
|
| 17 |
with patch(f"celery.bin.{daemon}.{daemon}.callback") as mock: |
| 18 |
cli_runner.invoke(celery, f"-A t.unit.bin.proj.daemon {daemon}") |
| 19 |
|
| 20 |
mock.assert_called_once() |
| 21 |
for param in "logfile", "pidfile", "uid", "gid", "umask", "executable": |
| 22 |
assert mock.call_args.kwargs[param] == getattr(config, f"{daemon}_{param}") |