コード例 #1
0
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)
コード例 #2
0
ファイル: test_base.py プロジェクト: seandst/molecule
def test_execute_cmdline_scenarios_destroy(
        config_instance, _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
コード例 #3
0
ファイル: reset.py プロジェクト: fauust/molecule
def reset(ctx, scenario_name):  # pragma: no cover
    """Reset molecule temporary folders."""
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {'subcommand': subcommand}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
コード例 #4
0
ファイル: create.py プロジェクト: westurner/molecule
def create(ctx, scenario_name, driver_name):  # pragma: no cover
    """Use the provisioner to start the instances."""
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {'subcommand': subcommand, 'driver_name': driver_name}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
コード例 #5
0
ファイル: lint.py プロジェクト: t2d/molecule
def lint(ctx, scenario_name):  # pragma: no cover
    """ Lint 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)
コード例 #6
0
ファイル: verify.py プロジェクト: AppleEducate/Essayhave
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)
コード例 #7
0
ファイル: lint.py プロジェクト: bonomali/molecule
def lint(ctx, scenario_name):  # pragma: no cover
    """Lint the role (dependency, lint)."""
    args = ctx.obj.get("args")
    subcommand = base._get_subcommand(__name__)
    command_args = {"subcommand": subcommand}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
コード例 #8
0
ファイル: side_effect.py プロジェクト: fauust/molecule
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)
コード例 #9
0
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)
コード例 #10
0
def converge(ctx, scenario_name, ansible_args):  # pragma: no cover
    """Use the provisioner to configure instances (dependency, create, prepare converge)."""
    args = ctx.obj.get("args")
    subcommand = base._get_subcommand(__name__)
    command_args = {"subcommand": subcommand}

    base.execute_cmdline_scenarios(scenario_name, args, command_args,
                                   ansible_args)
コード例 #11
0
ファイル: cleanup.py プロジェクト: AppleEducate/Essayhave
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)
コード例 #12
0
ファイル: idempotence.py プロジェクト: westurner/molecule
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)
コード例 #13
0
ファイル: reset.py プロジェクト: yemo-memeda/molecule
def reset(ctx, scenario_name):  # pragma: no cover
    """Reset molecule temporary folders."""
    args = ctx.obj.get("args")
    subcommand = base._get_subcommand(__name__)
    command_args = {"subcommand": subcommand}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
    for driver in drivers():
        driver.reset()
コード例 #14
0
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)
コード例 #15
0
ファイル: check.py プロジェクト: westurner/molecule
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)
コード例 #16
0
ファイル: test_base.py プロジェクト: AppleEducate/Essayhave
def test_execute_cmdline_scenarios_no_prune(config_instance, _patched_prune,
                                            _patched_execute_subcommand):
    # Subcommands should be executed but prune *should not* run when
    # destroy is 'never'
    scenario_name = "default"
    args = {}
    command_args = {"destroy": "never", "subcommand": "test"}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)

    assert _patched_execute_subcommand.called
    assert not _patched_prune.called
コード例 #17
0
ファイル: check.py プロジェクト: corserp/greet
def check(ctx, scenario_name):  # 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 = {
        'subcommand': subcommand,
    }

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
コード例 #18
0
def test_execute_cmdline_scenarios_no_prune(config_instance, _patched_prune,
                                            _patched_execute_subcommand):
    # Subcommands should be executed but prune *should not* run when
    # destroy is 'never'
    scenario_name = 'default'
    args = {}
    command_args = {'destroy': 'never', 'subcommand': 'test'}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)

    assert _patched_execute_subcommand.called
    assert not _patched_prune.called
コード例 #19
0
def destroy(ctx, scenario_name, driver_name, __all):  # pragma: no cover
    """ Use the provisioner to destroy the instances. """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
        'driver_name': driver_name,
    }

    if __all:
        scenario_name = None

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
コード例 #20
0
def test_execute_cmdline_scenarios(config_instance, _patched_print_matrix,
                                   _patched_execute_scenario):
    # Ensure execute_cmdline_scenarios runs normally:
    # - scenarios.print_matrix is called, which also indicates Scenarios
    #   was instantiated correctly
    # - execute_scenario is called once, indicating the function correctly
    #   loops over Scenarios.
    scenario_name = None
    args = {}
    command_args = {'destroy': 'always', 'subcommand': 'test'}
    base.execute_cmdline_scenarios(scenario_name, args, command_args)

    assert _patched_print_matrix.called_once_with()
    assert _patched_execute_scenario.call_count == 1
コード例 #21
0
def test(ctx, scenario_name, driver_name, __all, destroy):  # pragma: no cover
    """
    Test (lint, cleanup, destroy, dependency, syntax, create, prepare,
          converge, idempotence, side_effect, verify, cleanup, destroy).
    """

    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'destroy': destroy,
        'subcommand': subcommand,
        'driver_name': driver_name,
    }

    if __all:
        scenario_name = None

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
コード例 #22
0
ファイル: destroy.py プロジェクト: themr0c/molecule
def destroy(ctx, scenario_name, driver_name, __all,
            parallel):  # pragma: no cover
    """Use the provisioner to destroy the instances."""
    args = ctx.obj.get("args")
    subcommand = base._get_subcommand(__name__)
    command_args = {
        "parallel": parallel,
        "subcommand": subcommand,
        "driver_name": driver_name,
    }

    if __all:
        scenario_name = None

    if parallel:
        util.validate_parallel_cmd_args(command_args)

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
コード例 #23
0
ファイル: test.py プロジェクト: swipswaps/molecule
def test(ctx, scenario_name, driver_name, __all, destroy, parallel):  # pragma: no cover
    """Test (dependency, lint, cleanup, destroy, syntax, create, prepare, converge, idempotence, side_effect, verify, cleanup, destroy)."""
    args = ctx.obj.get("args")
    subcommand = base._get_subcommand(__name__)
    command_args = {
        "parallel": parallel,
        "destroy": destroy,
        "subcommand": subcommand,
        "driver_name": driver_name,
    }

    if __all:
        scenario_name = None

    if parallel:
        util.validate_parallel_cmd_args(command_args)

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
コード例 #24
0
def test_execute_cmdline_scenarios_exit_nodestroy(
    config_instance, _patched_execute_scenario, _patched_prune, _patched_sysexit
):
    # Ensure execute_cmdline_scenarios handles errors correctly when 'destroy'
    # is 'always':
    # - destroy subcommand is not run when execute_scenario raises SystemExit
    # - scenario is not pruned
    # - caught SystemExit is reraised
    scenario_name = "default"
    args = {}
    command_args = {"destroy": "never", "subcommand": "test"}

    _patched_execute_scenario.side_effect = SystemExit()

    # Catch the expected SystemExit reraise
    with pytest.raises(SystemExit):
        base.execute_cmdline_scenarios(scenario_name, args, command_args)

    assert _patched_execute_scenario.called
    assert not _patched_prune.called
    assert not _patched_sysexit.called