| 1 |
import pytest |
| 2 |
from click.testing import CliRunner |
| 3 |
|
| 4 |
from celery.app.log import Logging |
| 5 |
from celery.bin.celery import celery |
| 6 |
|
| 7 |
|
| 8 |
@pytest.fixture(scope='session') |
| 9 |
def use_celery_app_trap(): |
| 10 |
return False |
| 11 |
|
| 12 |
|
| 13 |
def test_cli(isolated_cli_runner: CliRunner): |
| 14 |
Logging._setup = True # To avoid hitting the logging sanity checks |
| 15 |
res = isolated_cli_runner.invoke( |
| 16 |
celery, |
| 17 |
["-A", "t.unit.bin.proj.app", "beat", "-S", "t.unit.bin.proj.scheduler.mScheduler"], |
| 18 |
catch_exceptions=True |
| 19 |
) |
| 20 |
assert res.exit_code == 1, (res, res.stdout) |
| 21 |
assert res.stdout.startswith("celery beat") |
| 22 |
assert "Configuration ->" in res.stdout |
| 23 |
|
| 24 |
|
| 25 |
def test_cli_quiet(isolated_cli_runner: CliRunner): |
| 26 |
Logging._setup = True # To avoid hitting the logging sanity checks |
| 27 |
res = isolated_cli_runner.invoke( |
| 28 |
celery, |
| 29 |
["-A", "t.unit.bin.proj.app", "--quiet", "beat", "-S", "t.unit.bin.proj.scheduler.mScheduler"], |
| 30 |
catch_exceptions=True |
| 31 |
) |
| 32 |
assert res.exit_code == 1, (res, res.stdout) |
| 33 |
assert not res.stdout.startswith("celery beat") |
| 34 |
assert "Configuration -> " not in res.stdout |