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_get_playbook(tmpdir, _instance):
x = os.path.join(_instance._config.scenario.directory, 'create.yml')
util.write_file(x, '')
assert x == _instance._get_playbook('create')
def test_additional_files_or_dirs_property(_instance):
tests_directory = _instance._config.verifier.directory
file1_file = os.path.join(tests_directory, 'file1.py')
file2_file = os.path.join(tests_directory, 'file2.py')
match1_file = os.path.join(tests_directory, 'match1.py')
match2_file = os.path.join(tests_directory, 'match2.py')
test_subdir = os.path.join(tests_directory, 'dir')
test_subdir_file = os.path.join(test_subdir, 'test_subdir_file.py')
os.mkdir(tests_directory)
os.mkdir(test_subdir)
for f in [file1_file, file2_file, match1_file, match2_file, test_subdir_file]:
util.write_file(f, '')
x = [file1_file, file2_file, match1_file, match2_file, test_subdir_file]
assert sorted(x) == sorted(_instance.additional_files_or_dirs)
def test_get_ansible_playbook_with_driver_key_when_playbook_key_missing(
tmpdir, _instance
):
x = os.path.join(_instance._config.scenario.directory, 'side_effect.yml')
util.write_file(x, '')
assert x == _instance._get_playbook('side_effect')
return
if self._precommit_command is None:
self.bake()
msg = 'Executing pre-commit on files found in {}/...'.format(
self._config.verifier.directory
)
LOG.info(msg)
try:
util.run_command(self._precommit_command, debug=self._config.debug)
msg = 'Lint completed successfully.'
LOG.success(msg)
except sh.ErrorReturnCode as e:
util.sysexit(e.exit_code)
def _rake(self,
rakefile,
debug=False,
out=util.callback_info,
err=util.callback_error):
"""
Executes rake against specified rakefile and returns a :func:`sh`
response object.
:param rakefile: A string containing path to the rakefile.
:param debug: An optional bool to toggle debug output.
:param out: An optional function to process STDOUT for underlying
:func:`sh` call.
:param err: An optional function to process STDERR for underlying
:func:`sh` call.
:return: :func:`sh` response object.
"""
kwargs = {
'_out': out,
'_err': err,
'raw_config_args': self._module.params['instance_raw_config_args'],
},
'provider': {
'name': self._module.params['provider_name'],
# NOTE(retr0h): Options provided here will be passed to
# Vagrant as "$provider_name.#{key} = #{value}".
'options': {
'memory': self._module.params['provider_memory'],
'cpus': self._module.params['provider_cpus'],
},
'raw_config_args': self._module.params['provider_raw_config_args'],
'override_args': self._module.params['provider_override_args'],
},
}
molecule.util.merge_dicts(
d['config']['options'], self._module.params['config_options']
)
molecule.util.merge_dicts(
d['provider']['options'], self._module.params['provider_options']
)
return d
def default_env(self):
return util.merge_dicts(os.environ, self._config.env)