Best Python code snippet using tempest_python
config_helper.py
Source:config_helper.py  
...141            ENABLE_SWIFT, ENABLE_HBASE_COMMON_LIB, SWIFT_LIB_URL,142            EXTJS_LIB_URL, AWAIT_AGENTS_TIMEOUT,143            AWAIT_MANAGER_STARTING_TIMEOUT]144# ng wide configs145def _load_json(path_to_file):146    data = f.get_file_text(path_to_file)147    return json.loads(data)148path_to_config = 'plugins/cdh/v5_3_0/resources/'149hdfs_confs = _load_json(path_to_config + 'hdfs-service.json')150namenode_confs = _load_json(path_to_config + 'hdfs-namenode.json')151datanode_confs = _load_json(path_to_config + 'hdfs-datanode.json')152secnamenode_confs = _load_json(path_to_config + 'hdfs-secondarynamenode.json')153yarn_confs = _load_json(path_to_config + 'yarn-service.json')154resourcemanager_confs = _load_json(155    path_to_config + 'yarn-resourcemanager.json')156nodemanager_confs = _load_json(path_to_config + 'yarn-nodemanager.json')157jobhistory_confs = _load_json(path_to_config + 'yarn-jobhistory.json')158oozie_service_confs = _load_json(path_to_config + 'oozie-service.json')159oozie_role_confs = _load_json(path_to_config + 'oozie-oozie_server.json')160hive_service_confs = _load_json(path_to_config + 'hive-service.json')161hive_metastore_confs = _load_json(path_to_config + 'hive-hivemetastore.json')162hive_hiveserver_confs = _load_json(path_to_config + 'hive-hiveserver2.json')163hive_webhcat_confs = _load_json(path_to_config + 'hive-webhcat.json')164hue_service_confs = _load_json(path_to_config + 'hue-service.json')165hue_role_confs = _load_json(path_to_config + 'hue-hue_server.json')166spark_service_confs = _load_json(path_to_config + 'spark-service.json')167spark_role_confs = _load_json(168    path_to_config + 'spark-spark_yarn_history_server.json')169zookeeper_service_confs = _load_json(path_to_config + 'zookeeper-service.json')170zookeeper_server_confs = _load_json(path_to_config + 'zookeeper-server.json')171hbase_confs = _load_json(path_to_config + 'hbase-service.json')172master_confs = _load_json(path_to_config + 'hbase-master.json')173regionserver_confs = _load_json(path_to_config + 'hbase-regionserver.json')174flume_service_confs = _load_json(path_to_config + 'flume-service.json')175flume_agent_confs = _load_json(path_to_config + 'flume-agent.json')176sentry_service_confs = _load_json(path_to_config + 'sentry-service.json')177sentry_server_confs = _load_json(path_to_config +178                                 'sentry-sentry_server.json')179solr_service_confs = _load_json(path_to_config + 'solr-service.json')180solr_server_confs = _load_json(path_to_config + 'solr-solr_server.json')181sqoop_service_confs = _load_json(path_to_config + 'sqoop-service.json')182sqoop_server_confs = _load_json(path_to_config +183                                'sqoop-sqoop_server.json')184ks_indexer_service_confs = _load_json(path_to_config +185                                      'ks_indexer-service.json')186ks_indexer_role_confs = _load_json(path_to_config +187                                   'ks_indexer-hbase_indexer.json')188impala_service_confs = _load_json(path_to_config + 'impala-service.json')189impala_catalogserver_confs = _load_json(path_to_config +190                                        'impala-catalogserver.json')191impala_impalad_confs = _load_json(path_to_config +192                                  'impala-impalad.json')193impala_llama_confs = _load_json(path_to_config +194                                'impala-llama.json')195impala_statestore_confs = _load_json(path_to_config +196                                     'impala-statestore.json')197priority_one_confs = _load_json(path_to_config + 'priority-one-confs.json')198def _prepare_value(value):199    if not value:200        return ""201    return value.replace('\n', ' ')202def _init_configs(confs, app_target, scope):203    cfgs = []204    for cfg in confs:205        priority = 1 if cfg['name'] in priority_one_confs else 2206        c = p.Config(cfg['name'], app_target, scope, priority=priority,207                     default_value=_prepare_value(cfg['value']),208                     description=cfg['desc'], is_optional=True)209        cfgs.append(c)210    return cfgs211def _get_ng_plugin_configs():...test_data_normalizer.py
Source:test_data_normalizer.py  
...11        if isinstance(item, dict):12            return frozenset({mapper(k): mapper(v) for k, v in item.items()}.items())13        return item14    return mapper(a) == mapper(b)15def _load_json(f):16    """Load json from f."""17    with (Path(__file__).parent / 'data/dataNormalizer' / f).open(encoding='utf-8') as fd:18        return json.load(fd)19def test_transforming_setup_py():20    """Test normalizing of data from setup.py."""21    data = _load_json('setup-py-from-mercator')22    expected = _load_json('setup-py-expected')23    assert normalize(data['items'][0]) == expected24def test_transforming_pkginfo():25    """Test normalizing of data from PKG-INFO."""26    data = _load_json('PKG-INFO-from-mercator')27    expected = _load_json('PKG-INFO-expected')28    assert normalize(data['items'][0]) == expected29def test_transforming_requirements_txt():30    """Test normalizing of data from requirements.txt."""31    data = _load_json('requirements-txt-from-mercator')32    expected = _load_json('requirements-txt-expected')33    assert normalize(data['items'][0]) == expected34def test_transforming_metadata_json():35    """Test normalizing of data from metadata.json."""36    data = _load_json('metadata-json-from-mercator')37    expected = _load_json('metadata-json-expected')38    assert normalize(data['items'][0]) == expected39def test_transforming_npm_shrinkwrap_data():40    """Test normalizing of npm's shrinkwrap.json data."""41    data = _load_json('npm-with-shrinkwrap-json-from-mercator')42    expected = _load_json('npm-with-shrinkwrap-json-expected')43    assert compare_dictionaries(normalize(data), expected)44def test_transforming_java():45    """Test normalizing of pom.xml data."""46    data = _load_json('pom-xml-from-mercator')47    expected = _load_json('pom-xml-expected')48    assert compare_dictionaries(normalize(data['items'][0]), expected)49def test_transforming_gradle():50    """Test normalizing of pom.xml data."""51    data = _load_json('gradle-from-mercator')52    expected = _load_json('gradle-expected')53    assert compare_dictionaries(normalize(data['items'][0]), expected)54def test_transforming_nuspec():55    """Test normalizing of nuspec data."""56    data = _load_json('nuspec-from-mercator')57    expected = _load_json('nuspec-expected')58    assert compare_dictionaries(normalize(data['items'][0]), expected)59def test_transforming_go_glide():60    """Test normalizing of go glide (with locked deps) data."""61    data = _load_json('go-glide-from-mercator')62    expected = _load_json('go-glide-expected')63    assert compare_dictionaries(normalize(data['items'][0]), expected)64def test_transforming_godeps():65    """Test normalizing of Godeps data."""66    data = _load_json('go-godeps-from-mercator')67    expected = _load_json('go-godeps-expected')68    assert compare_dictionaries(normalize(data['items'][0]), expected)69@pytest.mark.parametrize('data, expected', [70    ({'ecosystem': 'gofedlib', 'result': {71        'deps-main': [],72        'deps-packages': ['https://github.com/gorilla/context']}},73     {'ecosystem': 'gofedlib', 'dependencies': ['github.com/gorilla/context']}),74    ({'ecosystem': 'gofedlib',75      'result': {'deps-main': ['https://github.com/gorilla/sessions',76                               'https://github.com/gorilla/context'],77                 'deps-packages': ['https://github.com/gorilla/context']}},78     {'ecosystem': 'gofedlib', 'dependencies': ['github.com/gorilla/context',79                                                'github.com/gorilla/sessions']}),80])81def test_transforming_gofedlib_data(data, expected):...indexjson.py
Source:indexjson.py  
...15    _HERO_ROLE = "hero_role.json"16    _ROLE_INDEX = "role_index.json"17    def __init__(self, path_index, path_opendota_index):18        # opendota19        self.opendota_heroes = self._load_json(path_opendota_index20                                               / self._OPENDOTA_HERO)21        self.opendota_hero_abilities = self._load_json(22                                       path_opendota_index23                                       / self._OPENDOTA_HERO_ABILITIES)24        self.opendota_ability_ids = self._load_json(25                                    path_opendota_index26                                    / self._OPENDOTA_ABILITY_IDS)27        self.opendota_abilities = self._load_json(28                                  path_opendota_index29                                  / self._OPENDOTA_ABILITIES)30        self.opendota_item_ids = self._load_json(31                                 path_opendota_index32                                 / self._OPENDOTA_ITEM_IDS)33        self.opendota_items = self._load_json(34                                 path_opendota_index35                                 / self._OPENDOTA_ITEMS)36        # original37        self.pickbans = self._load_json(path_index/self._PICKBANS)38        self.hero_role = self._load_json(path_index/self._HERO_ROLE)39        self.role_index = self._load_json(path_index/self._ROLE_INDEX)40    def _load_json(self, path):41        with open(path) as f:42            result = json.load(f)43        return result44    def get_ability_id(self, abilityname):45        for abilityid, ability in self.opendota_ability_ids.items():46            if abilityname == ability:47                return(abilityid)48    def get_item_id(self, item):49        for itemid, itemname in self.opendota_item_ids.items():50            if item == itemname:51                return(itemid)52    def get_item_cost(self, item_name):53        return self.opendota_items[item_name]['cost']54    def get_ability_name(self, abilityid):...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!!
