Preload options reach plugin commands that have no ``**kwargs`` (#7894). ``celery.commands`` entry points such as Flower are not defined here. Celery still adds every preload option to those commands, and Click then passes the values into the callback. The documented receiver is ``u
()
| 86 | |
| 87 | |
| 88 | def test_plugin_command_accepts_preload_options(): |
| 89 | """Preload options reach plugin commands that have no ``**kwargs`` (#7894). |
| 90 | |
| 91 | ``celery.commands`` entry points such as Flower are not defined here. |
| 92 | Celery still adds every preload option to those commands, and Click then |
| 93 | passes the values into the callback. The documented receiver is |
| 94 | ``user_preload_options``. |
| 95 | """ |
| 96 | entered = [] |
| 97 | received = [] |
| 98 | |
| 99 | @click.command("plugin-without-kwargs") |
| 100 | @click.pass_context |
| 101 | def plugin_without_kwargs(ctx): |
| 102 | entered.append(True) |
| 103 | |
| 104 | receiver = _on_preload(received) |
| 105 | user_preload_options.connect(receiver) |
| 106 | try: |
| 107 | with _temporary_command(plugin_without_kwargs): |
| 108 | result = CliRunner().invoke( |
| 109 | celery, |
| 110 | [ |
| 111 | "-A", |
| 112 | "t.unit.bin.proj.pyramid_celery_app", |
| 113 | "plugin-without-kwargs", |
| 114 | "--ini", |
| 115 | "some_ini.ini", |
| 116 | ], |
| 117 | catch_exceptions=False, |
| 118 | ) |
| 119 | finally: |
| 120 | user_preload_options.disconnect(receiver) |
| 121 | |
| 122 | assert result.exit_code == 0, result.output |
| 123 | assert entered == [True] |
| 124 | assert len(received) == 1 |
| 125 | assert received[0]["ini"] == "some_ini.ini" |
| 126 | |
| 127 | |
| 128 | def test_decorated_command_accepts_preload_options_without_var_keyword(): |
nothing calls this directly
no test coverage detected