Beispiel #1
0
    def execute(self):
        """
        Executes linting/integration tests and returns None.

        Flake8 performs the code linting.
        Testinfra executes integration tests.

        :return: None
        """
        ansible = ansible_playbook.AnsiblePlaybook(
            self._molecule.config.config['ansible'], {},
            _env=self._molecule.env)

        testinfra_options = config.merge_dicts(
            self._molecule.driver.testinfra_args,
            self._molecule.verifier_options)

        testinfra_options['ansible_env'] = ansible.env
        if self._molecule.args.get('debug'):
            testinfra_options['debug'] = True
        if self._molecule.args.get('sudo'):
            testinfra_options['sudo'] = True

        tests = self._get_tests()
        if len(tests) > 0:
            if 'flake8' not in self._molecule.disabled:
                self._flake8(tests)
            self._testinfra(tests, **testinfra_options)
Beispiel #2
0
def test_merge_dicts():
    # example taken from python-anyconfig/anyconfig/__init__.py
    a = {'b': [{'c': 0}, {'c': 2}], 'd': {'e': 'aaa', 'f': 3}}
    b = {'a': 1, 'b': [{'c': 3}], 'd': {'e': 'bbb'}}
    x = {'a': 1, 'b': [{'c': 3}], 'd': {'e': "bbb", 'f': 3}}

    assert x == config.merge_dicts(a, b)
Beispiel #3
0
    def execute(self):
        """
        Executes linting/integration tests and returns None.

        Flake8 performs the code linting.
        Testinfra executes integration tests.

        :return: None
        """
        ansible = ansible_playbook.AnsiblePlaybook(
            self._molecule.config.config['ansible'], {},
            _env=self._molecule.env)

        testinfra_options = config.merge_dicts(
            self._molecule.driver.testinfra_args,
            self._molecule.config.config['verifier']['options'])

        testinfra_options['ansible_env'] = ansible.env
        if self._molecule.args.get('debug'):
            testinfra_options['debug'] = True
        if self._molecule.args.get('sudo'):
            testinfra_options['sudo'] = True

        tests = self._get_tests()
        if len(tests) > 0:
            if 'flake8' not in self._molecule.disabled:
                self._flake8(tests)
            self._testinfra(tests, **testinfra_options)
Beispiel #4
0
def molecule_vagrant_v1_config_using_env(molecule_v1_section_data,
                                         vagrant_v1_section_data_using_env,
                                         ansible_v1_section_data):
    return reduce(lambda x, y: config.merge_dicts(x, y), [
        molecule_v1_section_data, vagrant_v1_section_data_using_env,
        ansible_v1_section_data
    ])
Beispiel #5
0
def molecule_openstack_v1_config(molecule_v1_section_data,
                                 openstack_v1_section_data,
                                 ansible_v1_section_data):
    return reduce(lambda x, y: config.merge_dicts(x, y), [
        molecule_v1_section_data, openstack_v1_section_data,
        ansible_v1_section_data
    ])
Beispiel #6
0
def molecule_docker_cluster_v1_config(molecule_v1_section_data,
                                      docker_cluster_v1_section_data,
                                      ansible_v1_section_data):
    return reduce(lambda x, y: config.merge_dicts(x, y), [
        molecule_v1_section_data, docker_cluster_v1_section_data,
        ansible_v1_section_data
    ])
Beispiel #7
0
def molecule_vagrant_v1_config_using_env(molecule_v1_section_data,
                                         vagrant_v1_section_data_using_env,
                                         ansible_v1_section_data):
    return reduce(lambda x, y: config.merge_dicts(x, y), [
        molecule_v1_section_data, vagrant_v1_section_data_using_env,
        ansible_v1_section_data
    ])
Beispiel #8
0
def test_merge_dicts():
    # example taken from python-anyconfig/anyconfig/__init__.py
    a = {'b': [{'c': 0}, {'c': 2}], 'd': {'e': 'aaa', 'f': 3}}
    b = {'a': 1, 'b': [{'c': 3}], 'd': {'e': 'bbb'}}
    x = {'a': 1, 'b': [{'c': 3}], 'd': {'e': "bbb", 'f': 3}}

    assert x == config.merge_dicts(a, b)
Beispiel #9
0
def molecule_openstack_v1_config(molecule_v1_section_data,
                                 openstack_v1_section_data,
                                 ansible_v1_section_data):
    return reduce(lambda x, y: config.merge_dicts(x, y), [
        molecule_v1_section_data, openstack_v1_section_data,
        ansible_v1_section_data
    ])
Beispiel #10
0
def test_merge_dicts():
    # Example taken from python-anyconfig/anyconfig/__init__.py
    a = {'b': [{'c': 0}, {'c': 2}], 'd': {'e': 'aaa', 'f': 3}}
    b = {'a': 1, 'b': [{'c': 3}], 'd': {'e': 'bbb'}}
    expected = {'a': 1, 'b': [{'c': 3}], 'd': {'e': "bbb", 'f': 3}}
    result = config.merge_dicts(a, b)

    assert expected == result
Beispiel #11
0
def test_merge_dicts():
    # Example taken from python-anyconfig/anyconfig/__init__.py
    a = {'b': [{'c': 0}, {'c': 2}], 'd': {'e': 'aaa', 'f': 3}}
    b = {'a': 1, 'b': [{'c': 3}], 'd': {'e': 'bbb'}}
    expected = {'a': 1, 'b': [{'c': 3}], 'd': {'e': "bbb", 'f': 3}}
    result = config.merge_dicts(a, b)

    assert expected == result
Beispiel #12
0
def molecule_data(
        molecule_dependency_galaxy_section_data, molecule_driver_section_data,
        molecule_lint_section_data, molecule_platforms_section_data,
        molecule_provisioner_section_data, molecule_scenario_section_data,
        molecule_verifier_section_data):

    fixtures = [
        molecule_dependency_galaxy_section_data, molecule_driver_section_data,
        molecule_lint_section_data, molecule_platforms_section_data,
        molecule_provisioner_section_data, molecule_scenario_section_data,
        molecule_verifier_section_data
    ]

    return functools.reduce(lambda x, y: config.merge_dicts(x, y), fixtures)
Beispiel #13
0
def molecule_data(
        molecule_dependency_galaxy_section_data, molecule_driver_section_data,
        molecule_lint_section_data, molecule_platforms_section_data,
        molecule_provisioner_section_data, molecule_scenario_section_data,
        molecule_verifier_section_data):

    fixtures = [
        molecule_dependency_galaxy_section_data, molecule_driver_section_data,
        molecule_lint_section_data, molecule_platforms_section_data,
        molecule_provisioner_section_data, molecule_scenario_section_data,
        molecule_verifier_section_data
    ]

    return functools.reduce(lambda x, y: config.merge_dicts(x, y), fixtures)
Beispiel #14
0
    def bake(self):
        """
        Bake ansible-galaxy command so it's ready to execute and returns None.

        :return: None
        """
        requirements_file = self._config['ansible']['requirements_file']
        roles_path = os.path.join(self._config['molecule']['molecule_dir'],
                                  'roles')
        galaxy_default_options = {
            'force': True,
            'role-file': requirements_file,
            'roles-path': roles_path
        }
        galaxy_options = config.merge_dicts(galaxy_default_options,
                                            self._config['ansible']['galaxy'])

        self._galaxy = sh.ansible_galaxy.bake('install',
                                              _env=self._env,
                                              _out=self._out,
                                              _err=self._err,
                                              **galaxy_options)
    def bake(self):
        """
        Bake ansible-galaxy command so it's ready to execute and returns None.

        :return: None
        """
        requirements_file = self._config['dependency']['requirements_file']
        roles_path = os.path.join(self._config['molecule']['molecule_dir'],
                                  'roles')
        galaxy_default_options = {
            'force': True,
            'role-file': requirements_file,
            'roles-path': roles_path
        }
        galaxy_options = config.merge_dicts(
            galaxy_default_options, self._config['dependency']['options'])

        self._galaxy = sh.ansible_galaxy.bake(
            'install',
            _env=self._env,
            _out=self._out,
            _err=self._err,
            **galaxy_options)
Beispiel #16
0
    def execute(self):
        """
        Executes linting/integration tests, and returns None.

        Flake8 performs the code linting.
        Testinfra executes integration tests.

        :return: None
        """
        ansible = ansible_playbook.AnsiblePlaybook(
            self._molecule.config.config['ansible'], _env=self._molecule.env)

        testinfra_options = config.merge_dicts(
            self._molecule.driver.testinfra_args,
            self._molecule.verifier_options)
        testinfra_options['env'] = ansible.env
        testinfra_options['debug'] = self._molecule.args.get('--debug', False)
        testinfra_options['sudo'] = self._molecule.args.get('--sudo', False)

        tests_glob = self._get_tests()
        if len(tests_glob) > 0:
            self._flake8(tests_glob)
            self._testinfra(tests_glob, **testinfra_options)
Beispiel #17
0
def test_merge_dicts_instance_proxies(config_instance):
    a = {'a': 1}
    b = {'b': 2}
    result = config.merge_dicts(a, b)

    assert isinstance(result, dict)
def molecule_vagrant_config(molecule_section_data, vagrant_section_data, ansible_section_data):
    return reduce(
        lambda x, y: config.merge_dicts(x, y), [molecule_section_data, vagrant_section_data, ansible_section_data]
    )
Beispiel #19
0
def molecule_vagrant_config(molecule_section_data, vagrant_section_data,
                            ansible_section_data):
    return reduce(
        lambda x, y: config.merge_dicts(x, y),
        [molecule_section_data, vagrant_section_data, ansible_section_data])
Beispiel #20
0
def test_merge_dicts_instance_proxies(config_instance):
    a = {'a': 1}
    b = {'b': 2}
    result = config.merge_dicts(a, b)

    assert isinstance(result, dict)