def test_yield_map_children_direct(self, tmp_path_factory, quiet_logger, include_aliases, assertions): from yamlpath.enums import PathSeperators, PathSearchMethods from yamlpath.path import SearchTerms from yamlpath.func import get_yaml_data, get_yaml_editor from yamlpath.commands.yaml_paths import yield_children from itertools import zip_longest content = """--- aliases: - &aValue val2 hash: key1: val1 key2: *aValue key3: val3 """ processor = get_yaml_editor() yaml_file = create_temp_yaml_file(tmp_path_factory, content) (yaml_data, doc_loaded) = get_yaml_data(processor, quiet_logger, yaml_file) seen_anchors = [] results = [] for assertion, path in zip_longest( assertions, yield_children(quiet_logger, yaml_data, SearchTerms(False, PathSearchMethods.EQUALS, "*", "anchor"), PathSeperators.FSLASH, "", seen_anchors, search_anchors=True, include_value_aliases=include_aliases)): assert assertion == str(path)
def test_yield_raw_children_direct(self, tmp_path_factory, quiet_logger): from yamlpath.enums import PathSeperators, PathSearchMethods from yamlpath.path import SearchTerms from yamlpath.func import get_yaml_data, get_yaml_editor from yamlpath.commands.yaml_paths import yield_children from itertools import zip_longest content = """some raw text value """ processor = get_yaml_editor() yaml_file = create_temp_yaml_file(tmp_path_factory, content) yaml_data = get_yaml_data(processor, quiet_logger, yaml_file) seen_anchors = [] assertions = ["/"] results = [] for assertion, path in zip_longest( assertions, yield_children(quiet_logger, yaml_data, SearchTerms(False, PathSearchMethods.STARTS_WITH, "*", "some"), PathSeperators.FSLASH, "", seen_anchors, search_anchors=False, include_key_aliases=False, include_value_aliases=False)): assert assertion == str(path)
def test_yield_seq_children_direct(self, tmp_path_factory, quiet_logger): from yamlpath.enums import PathSeperators, PathSearchMethods from yamlpath.path import SearchTerms from yamlpath.func import get_yaml_data, get_yaml_editor from yamlpath.commands.yaml_paths import yield_children from itertools import zip_longest content = """--- - &value Test value - value - *value """ processor = get_yaml_editor() yaml_file = create_temp_yaml_file(tmp_path_factory, content) (yaml_data, doc_loaded) = get_yaml_data(processor, quiet_logger, yaml_file) seen_anchors = [] assertions = ["/&value", "/[1]"] results = [] for assertion, path in zip_longest( assertions, yield_children(quiet_logger, yaml_data, SearchTerms(False, PathSearchMethods.EQUALS, "*", "value"), PathSeperators.FSLASH, "", seen_anchors, search_anchors=True, include_aliases=False)): assert assertion == str(path)