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_command_verify_testinfra_precommit(
scenario_to_test, with_scenario, scenario_name
):
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('create', **options)
pytest.helpers.run_command(cmd)
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('converge', **options)
pytest.helpers.run_command(cmd)
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('verify', **options)
pytest.helpers.run_command(cmd)
def test_idempotence_raises(scenario_to_test, with_scenario, scenario_name):
options = {'scenario_name': scenario_name, 'all': True, 'destroy': 'never'}
cmd = sh.molecule.bake('test', **options)
with pytest.raises(sh.ErrorReturnCode_2) as e:
pytest.helpers.run_command(cmd)
assert 2 == e.value.exit_code
def test_command_prepare(scenario_to_test, with_scenario, scenario_name):
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('create', **options)
pytest.helpers.run_command(cmd)
cmd = sh.molecule.bake('prepare', **options)
pytest.helpers.run_command(cmd)
def test_command_verify_goss(scenario_to_test, with_scenario, scenario_name):
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('create', **options)
pytest.helpers.run_command(cmd)
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('converge', **options)
pytest.helpers.run_command(cmd)
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('verify', **options)
pytest.helpers.run_command(cmd)
def test_command_verify_goss(scenario_to_test, with_scenario, scenario_name):
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('create', **options)
pytest.helpers.run_command(cmd)
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('converge', **options)
pytest.helpers.run_command(cmd)
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('verify', **options)
pytest.helpers.run_command(cmd)
def test_command_init_scenario_as_default_without_default_scenario(temp_dir):
role_directory = os.path.join(temp_dir.strpath, 'test-role')
options = {'role_name': 'test-role'}
cmd = sh.molecule.bake('init', 'role', **options)
pytest.helpers.run_command(cmd)
pytest.helpers.metadata_lint_update(role_directory)
with change_dir_to(role_directory):
molecule_directory = pytest.helpers.molecule_directory()
scenario_directory = os.path.join(molecule_directory, 'default')
shutil.rmtree(scenario_directory)
options = {'scenario_name': 'default', 'role_name': 'test-role'}
cmd = sh.molecule.bake('init', 'scenario', **options)
pytest.helpers.run_command(cmd)
assert os.path.isdir(scenario_directory)
def test_command_syntax(scenario_to_test, with_scenario, scenario_name):
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('syntax', **options)
pytest.helpers.run_command(cmd)
def test_plugins(scenario_to_test, with_scenario, scenario_name):
options = {'scenario_name': scenario_name, 'all': True}
cmd = sh.molecule.bake('test', **options)
pytest.helpers.run_command(cmd)
def test_command_verify_inspec(scenario_to_test, with_scenario, scenario_name):
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('create', **options)
pytest.helpers.run_command(cmd)
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('converge', **options)
pytest.helpers.run_command(cmd)
options = {'scenario_name': scenario_name}
cmd = sh.molecule.bake('verify', **options)
pytest.helpers.run_command(cmd)
def test_command_init_role_with_template(temp_dir):
role_name = 'test-init'
role_directory = os.path.join(temp_dir.strpath, role_name)
options = {
'url': 'https://github.com/ansible/molecule-cookiecutter.git',
'no_input': True,
'role_name': role_name,
}
cmd = sh.molecule.bake('init', 'template', **options)
pytest.helpers.run_command(cmd)
pytest.helpers.metadata_lint_update(role_directory)
with change_dir_to(role_directory):
cmd = sh.molecule.bake('test')
pytest.helpers.run_command(cmd)