Beispiel #1
0
def test_os_walk(temp_dir):
    scenarios = ['scenario1', 'scenario2', 'scenario3']
    molecule_directory = config.molecule_directory(temp_dir.strpath)
    for scenario in scenarios:
        scenario_directory = os.path.join(molecule_directory, scenario)
        molecule_file = config.molecule_file(scenario_directory)
        os.makedirs(scenario_directory)
        open(molecule_file, 'a').close()

    result = [f for f in util.os_walk(molecule_directory, 'molecule.yml')]
    assert 3 == len(result)
Beispiel #2
0
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
    assert s.created
    assert not s.driver
Beispiel #3
0
    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))
Beispiel #4
0
    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))
Beispiel #5
0
def get_molecule_file(path):
    return config.molecule_file(path)
Beispiel #6
0
def test_molecule_file():
    assert '/foo/bar/molecule.yml' == config.molecule_file('/foo/bar')
Beispiel #7
0
def test_molecule_file():
    assert "/foo/bar/molecule.yml" == config.molecule_file("/foo/bar")
Beispiel #8
0
def test_molecule_file():
    assert '/foo/bar/molecule.yml' == config.molecule_file('/foo/bar')
Beispiel #9
0
def molecule_file(molecule_scenario_directory, molecule_ephemeral_directory):
    return config.molecule_file(molecule_scenario_directory)
Beispiel #10
0
def get_molecule_file(path: str) -> str:
    return config.molecule_file(path)