def test_get_configs_calls_verify_scenario_name( mocker, config_instance, patched_verify_configs, patched_base_filter_configs_for_scenario, patched_scenario_name): patched_base_filter_configs_for_scenario.return_value = [config_instance] base.get_configs({}, {'scenario_name': 'default'}) patched_scenario_name.assert_called_once_with( patched_base_filter_configs_for_scenario.return_value, 'default')
def test_get_configs_filter_configs_for_scenario( mocker, patched_verify_configs, patched_base_filter_configs_for_scenario, patched_verify_scenario_name, ): base.get_configs({}, {'scenario_name': 'default'}) patched_base_filter_configs_for_scenario.assert_called_once_with( 'default', [])
def test(ctx, scenario_name, driver_name, __all, destroy): # pragma: no cover """ Test (destroy, create, converge, lint, verify, destroy). """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, 'driver_name': driver_name, } if __all: scenario_name = None s = scenarios.Scenarios( base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: try: for term in scenario.sequence: base.execute_subcommand(scenario.config, term) except SystemExit: if destroy == 'always': msg = ('An error occured during the test sequence. ' 'Cleaning up.') LOG.warn(msg) base.execute_subcommand(scenario.config, 'destroy') util.sysexit() raise
def test(ctx, scenario_name, driver_name, __all, destroy): # pragma: no cover """ Test (lint, destroy, dependency, syntax, create, prepare, converge, idempotence, side_effect, verify, 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 s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: try: for term in scenario.sequence: base.execute_subcommand(scenario.config, term) except SystemExit: if destroy == 'always': msg = ('An error occured during the test sequence. ' 'Cleaning up.') LOG.warn(msg) base.execute_subcommand(scenario.config, 'destroy') util.sysexit() raise
def matrix(ctx, scenario_name, subcommand): # pragma: no cover """List matrix of steps used to test instances.""" args = ctx.obj.get("args") command_args = {"subcommand": subcommand} s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name) s.print_matrix()
def login(ctx, host, scenario_name): # pragma: no cover """Log in to one instance.""" args = ctx.obj.get("args") subcommand = base._get_subcommand(__name__) command_args = {"subcommand": subcommand, "host": host} s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name) for scenario in s.all: base.execute_subcommand(scenario.config, subcommand)
def test_get_configs(config_instance): molecule_file = config_instance.molecule_file data = config_instance.config util.write_file(molecule_file, util.safe_dump(data)) result = base.get_configs({}, {}) assert 1 == len(result) assert isinstance(result, list) assert isinstance(result[0], config.Config)
def test_get_configs(config_instance): molecule_file = config_instance.molecule_file data = config_instance.config util.write_file(molecule_file, util.safe_dump(data)) result = base.get_configs({}, {}) assert 1 == len(result) assert isinstance(result, list) assert isinstance(result[0], config.Config)
def lint(ctx, scenario_name): # pragma: no cover """ Lint the role. """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, 'scenario_name': scenario_name, } for c in base.get_configs(args, command_args): Lint(c).execute()
def syntax(ctx, scenario_name): # pragma: no cover """ Use a provisioner to syntax check the role. """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, 'scenario_name': scenario_name, } for c in base.get_configs(args, command_args): Syntax(c).execute()
def destruct(ctx, scenario_name): # pragma: no cover """ Use a provisioner to destruct instances. """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, 'scenario_name': scenario_name, } for c in base.get_configs(args, command_args): Destruct(c).execute()
def dependency(ctx, scenario_name): # pragma: no cover """ Mange the role's dependencies. """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, 'scenario_name': scenario_name, } for c in base.get_configs(args, command_args): Dependency(c).execute()
def verify(ctx, scenario_name): # pragma: no cover """ Run automated tests against instances. """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, 'scenario_name': scenario_name, } for c in base.get_configs(args, command_args): Verify(c).execute()
def login(ctx, host, scenario_name): # pragma: no cover """ Log in to one instance. """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, 'host': host, 'scenario_name': scenario_name, } for c in base.get_configs(args, command_args): Login(c).execute()
def lint(ctx, scenario_name): # pragma: no cover """ Lint the role. """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, } s = scenarios.Scenarios( base.get_configs(args, command_args), scenario_name) for c in s.all: Lint(c).execute()
def dependency(ctx, scenario_name): # pragma: no cover """ Mange the role's dependencies. """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, } s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name) for c in s.all: Dependency(c).execute()
def create(ctx, scenario_name, driver_name): # pragma: no cover """ Start instances. """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, 'scenario_name': scenario_name, 'driver_name': driver_name, } for c in base.get_configs(args, command_args): Create(c).execute()
def idempotence(ctx, scenario_name): # pragma: no cover """ Use a provisioner to configure the instances and parse the output to determine idempotence. """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, 'scenario_name': scenario_name, } for c in base.get_configs(args, command_args): Idempotence(c).execute()
def converge(ctx, scenario_name): # pragma: no cover """ Use a provisioner to configure instances (create, converge). """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, 'scenario_name': scenario_name, } for c in base.get_configs(args, command_args): for task in c.scenario.converge_sequence: command_module = getattr(molecule.command, task) command = getattr(command_module, task.capitalize()) command(c).execute()
def login(ctx, host, scenario_name): # pragma: no cover """ Log in to one instance. """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, 'host': host, } s = scenarios.Scenarios( base.get_configs(args, command_args), scenario_name) for scenario in s.all: base.execute_subcommand(scenario.config, subcommand)
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, } s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence: base.execute_subcommand(scenario.config, term)
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, } s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence: base.execute_subcommand(scenario.config, term)
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, } s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence: base.execute_subcommand(scenario.config, term)
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, } s = scenarios.Scenarios( base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence: base.execute_subcommand(scenario.config, term)
def converge(ctx, scenario_name, ansible_args): # pragma: no cover """ Use the provisioner to configure instances (create, converge). """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, } s = scenarios.Scenarios(base.get_configs(args, command_args, ansible_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence: base.execute_subcommand(scenario.config, term)
def test(ctx, scenario_name, driver_name): # pragma: no cover """ Test (destroy, create, converge, lint, verify, destroy). """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, 'scenario_name': scenario_name, 'driver_name': driver_name, } for c in base.get_configs(args, command_args): for task in c.scenario.test_sequence: command_module = getattr(molecule.command, task) command = getattr(command_module, task.capitalize()) command(c).execute()
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, } s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence: base.execute_subcommand(scenario.config, term)
def converge(ctx, scenario_name, ansible_args): # pragma: no cover """ Use the provisioner to configure instances (create, converge). """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, } s = scenarios.Scenarios( base.get_configs(args, command_args, ansible_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence: base.execute_subcommand(scenario.config, term)
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, } s = scenarios.Scenarios( base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence: base.execute_subcommand(scenario.config, term)
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, } s = scenarios.Scenarios( base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence: base.execute_subcommand(scenario.config, term)
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, } s = scenarios.Scenarios( base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence: base.execute_subcommand(scenario.config, term)
def check(ctx, scenario_name): # pragma: no cover """ Use a provisioner to perform a Dry-Run (create, converge, create). """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, } s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name) for c in s.all: for task in c.scenario.check_sequence: command_module = getattr(molecule.command, task) command = getattr(command_module, task.capitalize()) command(c).execute()
def create(ctx, scenario_name, driver_name): # pragma: no cover """ Start instances. """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, 'driver_name': driver_name, } s = scenarios.Scenarios( base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence: base.execute_subcommand(scenario.config, term)
def destroy(ctx, scenario_name, driver_name, __all): # pragma: no cover """ Destroy instances. """ args = ctx.obj.get('args') command_args = { 'subcommand': __name__, 'driver_name': driver_name, } if __all: scenario_name = None s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name) for c in s.all: Destroy(c).execute()
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, } s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for action in scenario.sequence: scenario.config.action = action base.execute_subcommand(scenario.config, action)
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, } s = scenarios.Scenarios( base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for action in scenario.sequence: scenario.config.action = action base.execute_subcommand(scenario.config, action)
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, } s = scenarios.Scenarios( base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence: base.execute_subcommand(scenario.config, term)
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, } s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence: base.execute_subcommand(scenario.config, term)
def list(ctx, scenario_name, format): # pragma: no cover """ Lists status of instances. """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, 'format': format, } statuses = [] s = scenarios.Scenarios( base.get_configs(args, command_args), scenario_name) for scenario in s: statuses.extend(base.execute_subcommand(scenario.config, subcommand)) headers = [util.title(name) for name in status.get_status()._fields] if format == 'simple' or format == 'plain': table_format = 'simple' if format == 'plain': headers = [] table_format = format _print_tabulate_data(headers, statuses, table_format) else: _print_yaml_data(headers, statuses)
def test_get_configs_calls_verify_configs(patched_verify_configs): base.get_configs({}, {}) patched_verify_configs.assert_called_once_with([])