How to use _find_value method in tempest

Best Python code snippet using tempest_python

repository_util.py

Source:repository_util.py Github

copy

Full Screen

...75 Please use Script.repository_util.create_repo_files() instead.76 """77 from resource_management.libraries.script import Script78 return RepositoryUtil(Script.get_config(), set()).create_repo_files()79def _find_value(dictionary, key, default=None):80 """81 Helper to find a value in a dictionary82 """83 if key not in dictionary:84 return default85 return dictionary[key]86class CommandRepositoryFeature(object):87 def __init__(self, feat_dict):88 """89 :type feat_dict dict90 """91 self.pre_installed = _find_value(feat_dict, "preInstalled", default=False)92 self.scoped = _find_value(feat_dict, "scoped", default=True)93class CommandRepository(object):94 """95 Class that encapsulates the representation of repositories passed in a command. This class96 should match the CommandRepository class.97 """98 def __init__(self, repo_object):99 """100 :type repo_object dict|basestring101 """102 if isinstance(repo_object, dict):103 json_dict = dict(repo_object) # strict dict(from ConfigDict) to avoid hidden type conversions104 elif isinstance(repo_object, basestring):105 json_dict = json.loads(repo_object)106 else:107 raise Fail("Cannot deserialize command repository {0}".format(str(repo_object)))108 # version_id is the primary id of the repo_version table in the database109 self.version_id = _find_value(json_dict, 'repoVersionId')110 self.stack_name = _find_value(json_dict, 'stackName')111 self.version_string = _find_value(json_dict, 'repoVersion')112 self.repo_filename = _find_value(json_dict, 'repoFileName')113 self.feat = CommandRepositoryFeature(_find_value(json_dict, "feature", default={}))114 self.items = []115 repos_def = _find_value(json_dict, 'repositories')116 if repos_def is not None:117 if not isinstance(repos_def, list):118 repos_def = [repos_def]119 for repo_def in repos_def:120 self.items.append(CommandRepositoryItem(self, repo_def))121class CommandRepositoryItem(object):122 """123 Class that represents the entries of a CommandRepository. This isn't meant to be instantiated124 outside a CommandRepository125 """126 def __init__(self, repo, json_dict):127 """128 :type repo CommandRepository129 :type json_dict dict130 """131 self._repo = repo132 self.repo_id = _find_value(json_dict, 'repoId') # this is the id within the repo file, not an Ambari artifact133 self.repo_name = _find_value(json_dict, 'repoName')134 self.distribution = _find_value(json_dict, 'distribution')135 self.components = _find_value(json_dict, 'components')136 self.base_url = _find_value(json_dict, 'baseUrl')137 self.mirrors_list = _find_value(json_dict, 'mirrorsList')138 self.tags = set(_find_value(json_dict, 'tags', default=[]))139 self.ambari_managed = _find_value(json_dict, 'ambariManaged', default=True)140 self.ubuntu_components = [self.distribution if self.distribution else self.repo_name] + \141 [self.components.replace(",", " ") if self.components else UBUNTU_REPO_COMPONENTS_POSTFIX]...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful