Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_patched_execute_scenario,
_patched_prune,
_patched_execute_subcommand,
_patched_sysexit,
):
# Ensure execute_cmdline_scenarios handles errors correctly when 'destroy'
# is 'always':
# - cleanup and destroy subcommands are run when execute_scenario
# raises SystemExit
# - scenario is pruned
scenario_name = 'default'
args = {}
command_args = {'destroy': 'always', 'subcommand': 'test'}
_patched_execute_scenario.side_effect = SystemExit()
base.execute_cmdline_scenarios(scenario_name, args, command_args)
assert _patched_execute_subcommand.call_count == 2
# pull out the second positional call argument for each call,
# which is the called subcommand. 'cleanup' and 'destroy' should be called.
assert _patched_execute_subcommand.call_args_list[0][0][1] == 'cleanup'
assert _patched_execute_subcommand.call_args_list[1][0][1] == 'destroy'
assert _patched_prune.called
assert _patched_sysexit.called
def cleanup(ctx, scenario_name): # pragma: no cover
"""
Use the provisioner to cleanup any changes made to external systems during
the stages of testing.
"""
args = ctx.obj.get('args')
subcommand = base._get_subcommand(__name__)
command_args = {'subcommand': subcommand}
base.execute_cmdline_scenarios(scenario_name, args, command_args)
def prepare(ctx, scenario_name, driver_name, force): # pragma: no cover
"""
Use the provisioner to prepare the instances into a particular starting
state.
"""
args = ctx.obj.get('args')
subcommand = base._get_subcommand(__name__)
command_args = {
'subcommand': subcommand,
'driver_name': driver_name,
'force': force,
}
base.execute_cmdline_scenarios(scenario_name, args, command_args)
def side_effect(ctx, scenario_name): # pragma: no cover
""" Use the provisioner to perform side-effects to the instances. """
args = ctx.obj.get('args')
subcommand = base._get_subcommand(__name__)
command_args = {'subcommand': subcommand}
base.execute_cmdline_scenarios(scenario_name, args, command_args)
def syntax(ctx, scenario_name): # pragma: no cover
""" Use the provisioner to syntax check the role. """
args = ctx.obj.get('args')
subcommand = base._get_subcommand(__name__)
command_args = {'subcommand': subcommand}
base.execute_cmdline_scenarios(scenario_name, args, command_args)
def check(ctx, scenario_name, parallel): # pragma: no cover
"""
Use the provisioner to perform a Dry-Run (destroy, dependency, create,
prepare, converge).
"""
args = ctx.obj.get('args')
subcommand = base._get_subcommand(__name__)
command_args = {'parallel': parallel, 'subcommand': subcommand}
if parallel:
util.validate_parallel_cmd_args(command_args)
base.execute_cmdline_scenarios(scenario_name, args, command_args)
def dependency(ctx, scenario_name): # pragma: no cover
""" Manage the role's dependencies. """
args = ctx.obj.get('args')
subcommand = base._get_subcommand(__name__)
command_args = {'subcommand': subcommand}
base.execute_cmdline_scenarios(scenario_name, args, command_args)
def verify(ctx, scenario_name): # pragma: no cover
""" Run automated tests against instances. """
args = ctx.obj.get('args')
subcommand = base._get_subcommand(__name__)
command_args = {'subcommand': subcommand}
base.execute_cmdline_scenarios(scenario_name, args, command_args)
def idempotence(ctx, scenario_name): # pragma: no cover
"""
Use the provisioner to configure the instances and parse the output to
determine idempotence.
"""
args = ctx.obj.get('args')
subcommand = base._get_subcommand(__name__)
command_args = {'subcommand': subcommand}
base.execute_cmdline_scenarios(scenario_name, args, command_args)