How to use the molecule.command.base.execute_cmdline_scenarios function in molecule

To help you get started, we’ve selected a few molecule examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ansible / molecule / test / unit / command / test_base.py View on Github external
_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
github ansible / molecule / molecule / command / cleanup.py View on Github external
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)
github ansible / molecule / molecule / command / prepare.py View on Github external
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)
github ansible / molecule / molecule / command / side_effect.py View on Github external
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)
github ansible / molecule / molecule / command / syntax.py View on Github external
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)
github ansible / molecule / molecule / command / check.py View on Github external
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)
github ansible / molecule / molecule / command / dependency.py View on Github external
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)
github ansible / molecule / molecule / command / verify.py View on Github external
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)
github ansible / molecule / molecule / command / idempotence.py View on Github external
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)