continue
arg_spec[argname] = argtype
args.append(CephArgtype.to_argdesc(
- argtype, dict(name=arg), has_default=True, positional=False
+ argtype, dict(name=argname), has_default=True, positional=False
))
return desc, arg_spec, first_default, ' '.join(args)
@pytest.mark.parametrize(
- "prefix, args, response",
+ "prefix, can_format, args, response",
[
(
"alpha one",
+ True,
{"name": "moonbase"},
(
0,
# ---
(
"alpha one",
+ True,
{"name": "moonbase2", "format": "yaml"},
(
0,
# ---
(
"alpha one",
+ True,
{"name": "moonbase2", "format": "chocolate"},
(
-22,
# ---
(
"beta two",
+ True,
{"name": "blocker"},
(
0,
# ---
(
"beta two",
+ True,
{"name": "test", "format": "yaml"},
(
0,
# ---
(
"beta two",
+ True,
{"name": "test", "format": "plain"},
(
-22,
# ---
(
"gamma three",
+ True,
{},
(
0,
# ---
(
"gamma three",
+ True,
{"size": 1, "format": "json"},
(
0,
# ---
(
"gamma three",
+ True,
{"size": 1, "format": "plain"},
(
0,
# ---
(
"gamma three",
+ True,
{"size": 2, "format": "plain"},
(
0,
# ---
(
"gamma three",
+ True,
{"size": 2, "format": "xml"},
(
0,
# ---
(
"gamma three",
+ True,
{"size": 2, "format": "toml"},
(
-22,
# ---
(
"z_err",
+ False,
{"name": "foobar"},
(
0,
# ---
(
"z_err",
+ False,
{"name": "zamboni"},
(
-22,
# ---
(
"empty one",
+ False,
{"name": "zucchini"},
(
0,
# ---
(
"empty one",
+ False,
{"name": "pow"},
(
-5,
),
],
)
-def test_cli_with_decorators(prefix, args, response):
+def test_cli_with_decorators(prefix, can_format, args, response):
dd = DecoDemo()
- assert CLICommand.COMMANDS[prefix].call(dd, args, None) == response
+ cmd = CLICommand.COMMANDS[prefix]
+ assert cmd.call(dd, args, None) == response
+ # slighly hacky way to check that the CLI "knows" about a --format option
+ # checking the extra_args feature of the Decorators that provide them (Responder)
+ if can_format:
+ assert 'name=format,' in cmd.args
def test_error_response():