summaryrefslogtreecommitdiff
path: root/tests/sources
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-06-10 07:51:57 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-15 14:14:02 +0000
commit38671fb53f4522d046bed94699db8cc344ac2862 (patch)
treedc75c432d897d393d3a568290d45d762c7bde093 /tests/sources
parentfcef3658433f74a2f396ed353bb3534f0001f3d8 (diff)
downloadbuildstream-38671fb53f4522d046bed94699db8cc344ac2862.tar.gz
_yaml: Add 'as_str()' on ScalarNode and 'get_scalar()' on MappingNode
- 'get_scalar()' allows retrieving a scalar node from a mapping. - 'as_str()' casts a ScalarNode into a string (thus removing the node information). Both together, those replace 'node_get(mapping, key, type=str)' but also allow retrieving the 'Node' itself, which will allow in the future lazier provenance computation.
Diffstat (limited to 'tests/sources')
-rw-r--r--tests/sources/git.py10
-rw-r--r--tests/sources/previous_source_access/plugins/sources/foo_transform.py2
2 files changed, 6 insertions, 6 deletions
diff --git a/tests/sources/git.py b/tests/sources/git.py
index 45a2b827a..2b8a12997 100644
--- a/tests/sources/git.py
+++ b/tests/sources/git.py
@@ -760,7 +760,7 @@ def test_track_fetch(cli, tmpdir, datafiles, ref_format, tag, extra_commit):
result.assert_success()
element = _yaml.load(element_path)
- new_ref = _yaml.node_get(_yaml.node_get(element, dict, 'sources', [0]), str, 'ref')
+ new_ref = _yaml.node_get(element, dict, 'sources', [0]).get_str('ref')
if ref_format == 'git-describe' and tag:
# Check and strip prefix
@@ -857,8 +857,8 @@ def test_git_describe(cli, tmpdir, datafiles, ref_storage, tag_type):
assert 'annotated' in tag
assert _yaml.node_get(tag, bool, 'annotated') == (tag_type == 'annotated')
- assert {(_yaml.node_get(tag, str, 'tag'),
- _yaml.node_get(tag, str, 'commit'))
+ assert {(tag.get_str('tag'),
+ tag.get_str('commit'))
for tag in tags} == {('tag1', repo.rev_parse('tag1^{commit}')),
('tag2', repo.rev_parse('tag2^{commit}'))}
@@ -972,8 +972,8 @@ def test_git_describe_head_is_tagged(cli, tmpdir, datafiles, ref_storage, tag_ty
assert 'annotated' in tag
assert _yaml.node_get(tag, bool, 'annotated') == (tag_type == 'annotated')
- tag_name = _yaml.node_get(tag, str, 'tag')
- commit = _yaml.node_get(tag, str, 'commit')
+ tag_name = tag.get_str('tag')
+ commit = tag.get_str('commit')
assert (tag_name, commit) == ('tag', repo.rev_parse('tag^{commit}'))
checkout = os.path.join(str(tmpdir), 'checkout')
diff --git a/tests/sources/previous_source_access/plugins/sources/foo_transform.py b/tests/sources/previous_source_access/plugins/sources/foo_transform.py
index bec4f9913..cd0f621d5 100644
--- a/tests/sources/previous_source_access/plugins/sources/foo_transform.py
+++ b/tests/sources/previous_source_access/plugins/sources/foo_transform.py
@@ -32,7 +32,7 @@ class FooTransformSource(Source):
def configure(self, node):
self.node_validate(node, ['ref', *Source.COMMON_CONFIG_KEYS])
- self.ref = self.node_get_member(node, str, 'ref', None)
+ self.ref = node.get_str('ref', None)
def preflight(self):
pass