Best Python code snippet using molecule_python
testinfra.py
Source:testinfra.py
...102 env = util.merge_dicts(os.environ.copy(), self._config.env)103 env = util.merge_dicts(env, self._config.provisioner.env)104 return env105 @property106 def additional_files_or_dirs(self):107 files_list = []108 c = self._config.config109 for f in c['verifier']['additional_files_or_dirs']:110 glob_path = os.path.join(self._config.verifier.directory, f)111 glob_list = glob.glob(glob_path)112 if glob_list:113 files_list.extend(glob_list)114 return files_list115 def bake(self):116 """117 Bake a `testinfra` command so it's ready to execute and returns None.118 :return: None119 """120 options = self.options...
test_verifier_section.py
Source:test_verifier_section.py
1# Copyright (c) 2015-2018 Cisco Systems, Inc.2#3# Permission is hereby granted, free of charge, to any person obtaining a copy4# of this software and associated documentation files (the "Software"), to5# deal in the Software without restriction, including without limitation the6# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or7# sell copies of the Software, and to permit persons to whom the Software is8# furnished to do so, subject to the following conditions:9#10# The above copyright notice and this permission notice shall be included in11# all copies or substantial portions of the Software.12#13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING18# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER19# DEALINGS IN THE SOFTWARE.20import pytest21from molecule.model import schema_v322@pytest.fixture23def _model_verifier_section_data():24 return {25 "verifier": {26 "name": "testinfra",27 "enabled": True,28 "directory": "foo",29 "options": {"foo": "bar"},30 "env": {"FOO": "foo", "FOO_BAR": "foo_bar"},31 "additional_files_or_dirs": ["foo"],32 }33 }34@pytest.mark.parametrize("_config", ["_model_verifier_section_data"], indirect=True)35def test_verifier(_config):36 assert {} == schema_v3.validate(_config)37@pytest.fixture38def _model_verifier_errors_section_data():39 return {40 "verifier": {41 "name": int(),42 "enabled": str(),43 "directory": int(),44 "options": [],45 "env": {"foo": "foo", "foo-bar": "foo-bar"},46 "additional_files_or_dirs": [int()],47 }48 }49@pytest.mark.parametrize(50 "_config", ["_model_verifier_errors_section_data"], indirect=True51)52def test_verifier_has_errors(_config):53 x = {54 "verifier": [55 {56 "name": ["must be of string type"],57 "enabled": ["must be of boolean type"],58 "env": [59 {60 "foo": ["value does not match regex '^[A-Z0-9_-]+$'"],61 "foo-bar": ["value does not match regex '^[A-Z0-9_-]+$'"],62 }63 ],64 "directory": ["must be of string type"],65 "additional_files_or_dirs": [{0: ["must be of string type"]}],66 "options": ["must be of dict type"],67 }68 ]69 }70 assert x == schema_v3.validate(_config)71@pytest.fixture72def _model_verifier_allows_testinfra_section_data():73 return {"verifier": {"name": "testinfra"}}74@pytest.fixture75def _model_verifier_allows_ansible_section_data():76 return {"verifier": {"name": "ansible"}}77@pytest.mark.parametrize(78 "_config",79 [80 ("_model_verifier_allows_testinfra_section_data"),81 ("_model_verifier_allows_ansible_section_data"),82 ],83 indirect=True,84)85def test_verifier_allows_name(_config):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!