Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/tests/test_cli.py
Show All 20 Lines | |||||
CLI_CONFIG = """ | CLI_CONFIG = """ | ||||
scheduler: | scheduler: | ||||
cls: foo | cls: foo | ||||
args: {} | args: {} | ||||
""" | """ | ||||
def invoke(scheduler, catch_exceptions, args): | def invoke(scheduler, catch_exceptions, args, config=CLI_CONFIG): | ||||
runner = CliRunner() | runner = CliRunner() | ||||
with patch( | with patch( | ||||
"swh.scheduler.get_scheduler" | "swh.scheduler.get_scheduler" | ||||
) as get_scheduler_mock, tempfile.NamedTemporaryFile( | ) as get_scheduler_mock, tempfile.NamedTemporaryFile( | ||||
"a", suffix=".yml" | "a", suffix=".yml" | ||||
) as config_fd: | ) as config_fd: | ||||
config_fd.write(CLI_CONFIG) | config_fd.write(config) | ||||
config_fd.seek(0) | config_fd.seek(0) | ||||
get_scheduler_mock.return_value = scheduler | get_scheduler_mock.return_value = scheduler | ||||
args = [ | args = [ | ||||
"-C" + config_fd.name, | "-C" + config_fd.name, | ||||
] + args | ] + args | ||||
result = runner.invoke(cli, args, obj={"log_level": logging.WARNING}) | result = runner.invoke(cli, args, obj={"log_level": logging.WARNING}) | ||||
if not catch_exceptions and result.exception: | if not catch_exceptions and result.exception: | ||||
print(result.output) | print(result.output) | ||||
▲ Show 20 Lines • Show All 902 Lines • Show Last 20 Lines |