Best Python code snippet using avocado_python
yum.py
Source:yum.py
...34 self._cfgparser = None35 self._set_version(cmd)36 self._yum_base = None37 @property38 def repo_config_parser(self):39 if self._cfgparser is None:40 self._cfgparser = configparser.ConfigParser()41 self._cfgparser.read(self.REPO_FILE_PATH)42 return self._cfgparser43 @property44 def yum_base(self):45 if self._yum_base is None:46 if HAS_YUM_MODULE:47 self._yum_base = yum.YumBase()48 else:49 log.debug("%s module for Python is required to use the "50 "'provides' command. Using the basic support "51 "from rpm and %s commands", self.cmd, self.cmd)52 return self._yum_base...
test_app_collection_config_parser.py
Source:test_app_collection_config_parser.py
1import pytest2from ansible_self_service.l2_infrastructure.app_collection_config_parser import AppCollectionConfigValidationException, \3 YamlAppCollectionConfigParser4from ansible_self_service.l4_core.models import AppCategory, App5VALID_CATEGORY_NAME = 'Misc'6VALID_ITEM_NAME = 'Cowsay'7VALID_ITEM_DESCRIPTION = 'Let an ASCII cow say stuff in your terminal!'8VALID_CONFIG = f"""9categories:10 {VALID_CATEGORY_NAME}: {{}}11items:12 {VALID_ITEM_NAME}:13 description: |14 {VALID_ITEM_DESCRIPTION}15 categories:16 - {VALID_CATEGORY_NAME}17 image_url: https://upload.wikimedia.org/wikipedia/commons/8/80/Cowsay_Typical_Output.png18 playbook: playbooks/cowsay.yml19 params:20 ansible_become_password:21 type: secret22 mandatory: true23 requirements: > # any expression that we could use for a tasks "when" clause; items are ANDed24 - ansible_distribution == 'Ubuntu'25"""26INVALID_CONFIG = '''27this is not even YAML28'''29def test_parse_valid_file(tmpdir):30 config_file = tmpdir.join('self-service.yaml')31 config_file.write(VALID_CONFIG)32 repo_config_parser = YamlAppCollectionConfigParser()33 categories, apps = repo_config_parser.from_file(config_file)34 assert categories == [AppCategory(name=VALID_CATEGORY_NAME)]35 assert apps == [App(36 name=VALID_ITEM_NAME, description=VALID_ITEM_DESCRIPTION, categories=[AppCategory(name=VALID_CATEGORY_NAME)])37 ]38def test_parse_invalid_file(tmpdir):39 config_file = tmpdir.join('self-service.yaml')40 config_file.write(INVALID_CONFIG)41 repo_config_parser = YamlAppCollectionConfigParser()42 with pytest.raises(AppCollectionConfigValidationException):...
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!!