diff options
author | Benjamin Schubert <contact@benschubert.me> | 2019-06-09 14:22:35 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-15 14:14:02 +0000 |
commit | fcef3658433f74a2f396ed353bb3534f0001f3d8 (patch) | |
tree | a3c74347254332f06583fbdc1c6a6fc4411d21aa /tests | |
parent | f6616bc9d51a791aba1e177c61e27f768bebd9cb (diff) | |
download | buildstream-fcef3658433f74a2f396ed353bb3534f0001f3d8.tar.gz |
_yaml: add 'get_mapping()' to MappingNode
This allows to get a mapping node from another 'MappingNode',
replacing 'node_get(my_mapping, key, type=dict)'
Also changes all places where 'node_get' was called like that by
the new API.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/elements/filter/basic/element_plugins/dynamic.py | 2 | ||||
-rw-r--r-- | tests/format/include.py | 2 | ||||
-rw-r--r-- | tests/frontend/project/sources/fetch_source.py | 2 | ||||
-rw-r--r-- | tests/internals/yaml.py | 8 | ||||
-rw-r--r-- | tests/sources/previous_source_access.py | 2 |
5 files changed, 8 insertions, 8 deletions
diff --git a/tests/elements/filter/basic/element_plugins/dynamic.py b/tests/elements/filter/basic/element_plugins/dynamic.py index c6d128b72..b4a556244 100644 --- a/tests/elements/filter/basic/element_plugins/dynamic.py +++ b/tests/elements/filter/basic/element_plugins/dynamic.py @@ -5,7 +5,7 @@ from buildstream import Element, Scope class DynamicElement(Element): def configure(self, node): self.node_validate(node, ['split-rules']) - self.split_rules = self.node_get_member(node, dict, 'split-rules') + self.split_rules = node.get_mapping('split-rules') def preflight(self): pass diff --git a/tests/format/include.py b/tests/format/include.py index bfadce7ed..f2815ca31 100644 --- a/tests/format/include.py +++ b/tests/format/include.py @@ -213,7 +213,7 @@ def test_list_overide_does_not_fail_upon_first_composition(cli, datafiles): loaded = _yaml.load_data(result.output) # Assert that the explicitly overwritten public data is present - bst = _yaml.node_get(loaded, dict, 'bst') + bst = loaded.get_mapping('bst') assert 'foo-commands' in bst assert _yaml.node_get(bst, list, 'foo-commands') == ['need', 'this'] diff --git a/tests/frontend/project/sources/fetch_source.py b/tests/frontend/project/sources/fetch_source.py index f17c14029..4c265f99b 100644 --- a/tests/frontend/project/sources/fetch_source.py +++ b/tests/frontend/project/sources/fetch_source.py @@ -42,7 +42,7 @@ class FetchSource(Source): self.output_file = self.node_get_member(node, str, 'output-text') self.fetch_succeeds = {} if 'fetch-succeeds' in node: - fetch_succeeds_node = self.node_get_member(node, dict, 'fetch-succeeds') + fetch_succeeds_node = node.get_mapping('fetch-succeeds') for key, value in self.node_items(fetch_succeeds_node): self.fetch_succeeds[key] = value in ('True', 'true') diff --git a/tests/internals/yaml.py b/tests/internals/yaml.py index cd3bdc535..a553cbf0f 100644 --- a/tests/internals/yaml.py +++ b/tests/internals/yaml.py @@ -110,9 +110,9 @@ def test_node_get(datafiles): child = _yaml.node_get(base, dict, 'children', indices=[6]) assert_provenance(filename, 20, 8, child, 'mood') - extra = _yaml.node_get(base, dict, 'extra') + extra = base.get_mapping('extra') with pytest.raises(LoadError) as exc: - _yaml.node_get(extra, dict, 'old') + extra.get_mapping('old') assert exc.value.reason == LoadErrorReason.INVALID_DATA @@ -188,8 +188,8 @@ def test_composite_preserve_originals(datafiles): base_copy = _yaml.node_copy(base) _yaml.composite_dict(base_copy, overlay) - copy_extra = _yaml.node_get(base_copy, dict, 'extra') - orig_extra = _yaml.node_get(base, dict, 'extra') + copy_extra = base_copy.get_mapping('extra') + orig_extra = base.get_mapping('extra') # Test that the node copy has the overridden value... assert _yaml.node_get(copy_extra, str, 'old') == 'override' diff --git a/tests/sources/previous_source_access.py b/tests/sources/previous_source_access.py index 800e0ced5..50bfe383c 100644 --- a/tests/sources/previous_source_access.py +++ b/tests/sources/previous_source_access.py @@ -24,7 +24,7 @@ def test_custom_transform_source(cli, datafiles): # Set the project_dir alias in project.conf to the path to the tested project project_config_path = os.path.join(project, "project.conf") project_config = _yaml.load(project_config_path) - aliases = _yaml.node_get(project_config, dict, "aliases") + aliases = project_config.get_mapping("aliases") _yaml.node_set(aliases, "project_dir", "file://{}".format(project)) _yaml.dump(project_config, project_config_path) |