Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_config_private_member(_instance):
assert isinstance(_instance._config, config.Config)
def test_config_private_member(_instance):
assert isinstance(_instance._config, config.Config)
def test_config_private_member(_instance):
assert isinstance(_instance._config, config.Config)
def test_config_private_member(_instance):
assert isinstance(_instance._config, config.Config)
def test_get_data_loads_existing_state_file(temp_dir, molecule_data):
molecule_directory = config.molecule_directory(temp_dir.strpath)
scenario_directory = os.path.join(molecule_directory, 'default')
molecule_file = config.molecule_file(scenario_directory)
ephemeral_directory = config.molecule_ephemeral_directory(
scenario_directory)
state_file = os.path.join(ephemeral_directory, 'state.yml')
os.makedirs(ephemeral_directory)
data = {'converged': False, 'created': True, 'driver': None}
util.write_file(state_file, util.safe_dump(data))
pytest.helpers.write_molecule_file(molecule_file, molecule_data)
c = config.Config(molecule_file)
s = state.State(c)
assert not s.converged
def test_config_private_member(_instance):
assert isinstance(_instance._config, config.Config)
def execute(self):
"""
Execute the actions necessary to perform a `molecule init scenario` and
returns None.
:return: None
"""
scenario_name = self._command_args['scenario_name']
role_name = os.getcwd().split(os.sep)[-1]
role_directory = util.abs_path(os.path.join(os.getcwd(), os.pardir))
msg = 'Initializing new scenario {}...'.format(scenario_name)
LOG.info(msg)
molecule_directory = config.molecule_directory(
os.path.join(role_directory, role_name)
)
scenario_directory = os.path.join(molecule_directory, scenario_name)
if os.path.isdir(scenario_directory):
msg = (
'The directory molecule/{} exists. ' 'Cannot create new scenario.'
).format(scenario_name)
util.sysexit_with_message(msg)
driver_template = api.drivers()[
self._command_args['driver_name']
].template_dir()
if 'driver_template' in self._command_args:
self._validate_template_dir(self._command_args['driver_template'])
cli_driver_template = '{driver_template}/{driver_name}'.format(
def _init_new_scenario(command_args):
"""
Initialize a new scenario:
>>> molecule init scenario --scenario-name default --role-name foo
"""
scenario_name = command_args['scenario_name']
role_name = os.getcwd().split(os.sep)[-1]
role_directory = util.abs_path(os.path.join(os.getcwd(), os.pardir))
LOG.info('Initializing new scenario {}...'.format(scenario_name))
molecule_directory = config.molecule_directory(
os.path.join(role_directory, role_name))
scenario_directory = os.path.join(molecule_directory, scenario_name)
scenario_base_directory = os.path.dirname(scenario_directory)
if os.path.isdir(scenario_directory):
msg = ('The directory molecule/{} exists. '
'Cannot create new scenario.').format(scenario_name)
util.sysexit_with_message(msg)
scenario_base_directory = os.path.join(role_directory, role_name)
templates = [
'scenario/driver/{driver_name}'.format(**command_args),
'scenario/verifier/{verifier_name}'.format(**command_args),
]
for template in templates:
_process_templates(template, command_args, scenario_base_directory)
def __init__(self, old_molecule_file, driver_name):
self._old_molecule_file = old_molecule_file
if not os.path.isfile(old_molecule_file):
msg = 'Unable to find {}. Exiting.'.format(old_molecule_file)
util.sysexit_with_message(msg)
self._m = migrate.Migrate(old_molecule_file)
self._old_role_dir = os.path.join(os.path.dirname(old_molecule_file))
self._old_dot_molecule_dir = scenario.ephemeral_directory(self._old_role_dir)
self._old_test_dir = os.path.join(self._old_role_dir, 'tests')
self._old_playbook = os.path.join(self._old_role_dir, 'playbook.yml')
self._molecule_dir = config.molecule_directory(self._old_role_dir)
self._scenario_dir = os.path.join(self._molecule_dir, 'default')
self._test_dir = os.path.join(self._scenario_dir, 'tests')
self._molecule_file = config.molecule_file(self._scenario_dir)
self._role_name = os.path.basename(os.path.normpath(self._old_role_dir))
type=click.Choice(config.molecule_drivers()),
default='docker',
help='Name of driver to initialize. (docker)')
@click.option(
'--lint-name',
type=click.Choice(['ansible-lint']),
default='ansible-lint',
help='Name of lint to initialize. (ansible-lint)')
@click.option(
'--provisioner-name',
type=click.Choice(['ansible']),
default='ansible',
help='Name of provisioner to initialize. (ansible)')
@click.option('--role-name', required=True, help='Name of the role to create.')
@click.option(
'--scenario-name', required=True, help='Name of the scenario to create.')
@click.option(