MCPcopy Create free account
hub / github.com/celery/celery / test_plugin_command_accepts_preload_options

Function test_plugin_command_accepts_preload_options

t/unit/app/test_preload_cli.py:88–125  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

86
87
88def 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
128def test_decorated_command_accepts_preload_options_without_var_keyword():

Callers

nothing calls this directly

Calls 4

_on_preloadFunction · 0.85
_temporary_commandFunction · 0.85
connectMethod · 0.45
disconnectMethod · 0.45

Tested by

no test coverage detected