Exemple #1
0
    def _get_tests(self):
        """
        Get a list of test files from the verifier's directory.

        :return: list
        """
        return list(util.os_walk(self._config.verifier.directory, 'test_*.py'))
Exemple #2
0
    def _get_tests(self):
        """
        Walk the verifier's directory for tests and returns a list.

        :return: list
        """
        return [filename for filename in util.os_walk(self.directory, "test_*.yml")]
Exemple #3
0
    def prune(self):
        """
        Prune the scenario ephemeral directory files and returns None.

        "safe files" will not be pruned, including the ansible configuration
        and inventory used by this scenario, the scenario state file, and
        files declared as "safe_files" in the ``driver`` configuration
        declared in ``molecule.yml``.

        :return: None
        """
        LOG.info("Pruning extra files from scenario ephemeral directory")
        safe_files = [
            self.config.provisioner.config_file,
            self.config.provisioner.inventory_file,
            self.config.state.state_file,
        ] + self.config.driver.safe_files
        files = util.os_walk(self.ephemeral_directory, "*")
        for f in files:
            if not any(sf for sf in safe_files if fnmatch.fnmatch(f, sf)):
                os.remove(f)

        # Remove empty directories.
        for dirpath, dirs, files in os.walk(self.ephemeral_directory, topdown=False):
            if not dirs and not files:
                os.removedirs(dirpath)
Exemple #4
0
    def _get_files(self):
        """
        Walk the project directory for tests and returns a list.

        :return: list
        """
        excludes = [
            '.tox',
            '.git',
            '.vagrant',
            '.molecule',
        ]
        generators = [
            util.os_walk(self._config.project_directory, '*.yml', excludes),
            util.os_walk(self._config.project_directory, '*.yaml', excludes),
        ]

        return [f for g in generators for f in g]
Exemple #5
0
    def _get_tests(self):
        """
        Walk the verifier's directory for tests and returns a list.

        :return: list
        """
        return [
            filename for filename in util.os_walk(self.directory, 'test_*.py')
        ]
Exemple #6
0
    def _get_files(self):
        """
        Walk the project directory for tests and returns a list.

        :return: list
        """
        excludes = [
            '.tox',
            '.git',
            '.vagrant',
            '.molecule',
        ]
        generators = [
            util.os_walk(self._config.project_directory, '*.yml', excludes),
            util.os_walk(self._config.project_directory, '*.yaml', excludes),
        ]

        return [f for g in generators for f in g]
Exemple #7
0
    def _get_files(self):
        """
        Walk the project directory for tests and returns a list.

        :return: list
        """
        excludes = [
            '.git',
            '.tox',
            '.vagrant',
            '.venv',
            os.path.basename(self._config.verifier.directory),
        ]
        generators = [
            util.os_walk(self._config.project_directory, '*.yml', excludes),
            util.os_walk(self._config.project_directory, '*.yaml', excludes),
        ]

        return [f for g in generators for f in g]
Exemple #8
0
    def _get_tests(self):
        """
        Walk the verifier's directory for tests and returns a list.

        :return: list
        """
        return [
            filename for filename in util.os_walk(
                self._config.verifier.directory, 'test_*.py')
        ]
Exemple #9
0
    def _get_tests(self):
        """
        Walk the verifier's directory for tests and returns a list.

        :return: list
        """
        return sorted([
            filename for filename in util.os_walk(
                self.directory, "test_*.py", followlinks=True)
        ])
Exemple #10
0
def test_os_walk(temp_dir):
    scenarios = ["scenario1", "scenario2", "scenario3"]
    molecule_directory = pytest.helpers.molecule_directory()
    for scenario in scenarios:
        scenario_directory = os.path.join(molecule_directory, scenario)
        molecule_file = pytest.helpers.get_molecule_file(scenario_directory)
        os.makedirs(scenario_directory)
        util.write_file(molecule_file, "")

    result = [f for f in util.os_walk(molecule_directory, "molecule.yml")]
    assert 3 == len(result)
Exemple #11
0
def test_os_walk(temp_dir):
    scenarios = ['scenario1', 'scenario2', 'scenario3']
    molecule_directory = pytest.helpers.molecule_directory()
    for scenario in scenarios:
        scenario_directory = os.path.join(molecule_directory, scenario)
        molecule_file = pytest.helpers.get_molecule_file(scenario_directory)
        os.makedirs(scenario_directory)
        util.write_file(molecule_file, '')

    result = [f for f in util.os_walk(molecule_directory, 'molecule.yml')]
    assert 3 == len(result)
Exemple #12
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)
Exemple #13
0
    def prune(self):
        """
        Prune the ephemeral directory with the exception of safe files and
        returns None.

        :return: None
        """
        safe_files = [
            self._config.provisioner.config_file,
            self._config.provisioner.inventory_file,
            self._config.state.state_file,
        ] + self._config.driver.safe_files

        files = util.os_walk(self._config.scenario.ephemeral_directory, '*')
        for f in files:
            if all(sf not in f for sf in safe_files):
                os.remove(f)
Exemple #14
0
    def prune(self):
        """
        Prune the ephemeral directory with the exception of safe files and
        returns None.

        :return: None
        """
        safe_files = [
            self._config.provisioner.config_file,
            self._config.provisioner.inventory_file,
            self._config.state.state_file,
        ] + self._config.driver.safe_files
        files = util.os_walk(self._config.scenario.ephemeral_directory, '*')
        for f in files:
            if not any(sf for sf in safe_files if fnmatch.fnmatch(f, sf)):
                os.remove(f)

        # Remove empty directories.
        for dirpath, dirs, files in os.walk(
                self._config.scenario.ephemeral_directory, topdown=False):
            if not dirs and not files:
                os.removedirs(dirpath)
Exemple #15
0
    def prune(self):
        """
        Prune the ephemeral directory with the exception of safe files and
        returns None.

        :return: None
        """
        safe_files = [
            self._config.provisioner.config_file,
            self._config.provisioner.inventory_file,
            self._config.state.state_file,
        ] + self._config.driver.safe_files

        files = util.os_walk(self._config.scenario.ephemeral_directory, '*')
        for f in files:
            if all(sf not in f for sf in safe_files):
                os.remove(f)

        # Remove empty directories.
        for dirpath, dirs, files in os.walk(
                self._config.scenario.ephemeral_directory):
            if not dirs and not files:
                os.rmdir(dirpath)