def molecule_ephemeral_directory(_fixture_uuid): project_directory = 'test-project-{}'.format(_fixture_uuid) scenario_name = 'test-instance' return ephemeral_directory( os.path.join('molecule_test', project_directory, scenario_name) )
def molecule_ephemeral_directory(_fixture_uuid): project_directory = "test-project-{}".format(_fixture_uuid) scenario_name = "test-instance" return ephemeral_directory( os.path.join("molecule_test", project_directory, scenario_name) )
def molecule_ephemeral_directory(_fixture_uuid) -> str: project_directory = f"test-project-{_fixture_uuid}" scenario_name = "test-instance" return ephemeral_directory( os.path.join("molecule_test", project_directory, scenario_name) )
def test_command_dependency_shell(request, scenario_to_test, with_scenario, scenario_name): options = {'scenario_name': scenario_name} cmd = sh.molecule.bake('dependency', **options) pytest.helpers.run_command(cmd) dependency_role = os.path.join(ephemeral_directory('molecule'), 'dependency', 'shell', 'roles', 'timezone') assert os.path.isdir(dependency_role)
def test_command_dependency_shell(request, scenario_to_test, with_scenario, scenario_name): options = {"scenario_name": scenario_name} cmd = sh.molecule.bake("dependency", **options) pytest.helpers.run_command(cmd) dependency_role = os.path.join(ephemeral_directory("molecule"), "dependency", "shell", "roles", "timezone") assert os.path.isdir(dependency_role)
def test_command_dependency_shell(request, scenario_to_test, with_scenario, scenario_name): # FIXME(decentral1se): skipped due to failures on network access if request.getfixturevalue('driver_name') != 'docker': pytest.skip('Skipped to avoid network access failures') options = {'scenario_name': scenario_name} cmd = sh.molecule.bake('dependency', **options) pytest.helpers.run_command(cmd) dependency_role = os.path.join(ephemeral_directory('molecule'), 'dependency', 'shell', 'roles', 'timezone') assert os.path.isdir(dependency_role)
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))
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))
def test_ephemeral_directory_overriden_via_env_var_uses_absolute_path( monkeypatch): monkeypatch.setenv('MOLECULE_EPHEMERAL_DIRECTORY', '/foo/bar') assert '/foo/bar' == scenario.ephemeral_directory('foo/bar')
def molecule_ephemeral_directory(): project_directory = 'test-project' scenario_name = 'test-instance' return ephemeral_directory(os.path.join(project_directory, scenario_name))
def test_ephemeral_directory_OVERRIDDEN_via_env_var(monkeypatch): monkeypatch.setenv("MOLECULE_EPHEMERAL_DIRECTORY", "foo/bar") assert os.access(scenario.ephemeral_directory("foo/bar"), os.W_OK)
def test_ephemeral_directory(): assert '/foo/bar/.molecule' == scenario.ephemeral_directory('/foo/bar')
import glob import os import re import shutil try: from pathlib import Path except ImportError: from pathlib2 import Path import pytest from molecule import util from molecule import config from molecule.scenario import ephemeral_directory for d in glob.glob(os.path.join(ephemeral_directory('molecule'), '*')): if re.search('[A-Z]{5}$', d): shutil.rmtree(d) @pytest.helpers.register def write_molecule_file(filename, data): util.write_file(filename, util.safe_dump(data)) @pytest.helpers.register def os_split(s): rest, tail = os.path.split(s) if rest in ('', os.path.sep): return tail, return os_split(rest) + (tail, )
def test_ephemeral_directory_overriden_via_env_var(monkeypatch): monkeypatch.setenv('MOLECULE_EPHEMERAL_DIRECTORY', '.foo') assert '/foo/bar/.foo' == scenario.ephemeral_directory('/foo/bar')
def test_ephemeral_directory_overriden_via_env_var(monkeypatch): monkeypatch.setenv('MOLECULE_EPHEMERAL_DIRECTORY', 'foo/bar') assert os.access(scenario.ephemeral_directory('foo/bar'), os.W_OK)
def test_ephemeral_directory(): # assure we can write to ephemeral directory assert os.access(scenario.ephemeral_directory("foo/bar"), os.W_OK)
def test_ephemeral_directory(): e_dir = os.path.join(tempfile.gettempdir(), 'foo/bar') assert e_dir == scenario.ephemeral_directory('foo/bar')
def test_ephemeral_directory_OVERRIDDEN_via_env_var_uses_absolute_path( monkeypatch): monkeypatch.setenv("MOLECULE_EPHEMERAL_DIRECTORY", "foo/bar") assert os.path.isabs(scenario.ephemeral_directory())
def test_ephemeral_directory_overriden_via_env_var(monkeypatch): monkeypatch.setenv('MOLECULE_EPHEMERAL_DIRECTORY', 'foo/bar') e_dir = os.path.join(tempfile.gettempdir(), 'foo/bar') assert e_dir == scenario.ephemeral_directory('foo/bar')