diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-07-16 18:31:19 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-17 08:26:26 +0000 |
commit | b2a91466511f60e33e2e77fed2bf9c60bc31803d (patch) | |
tree | a34e90c980bf95d96c5db60a822e8954edf5c150 /tests | |
parent | a7ac4fed521881f54b76b199233c5aee3ba1f1ce (diff) | |
download | buildstream-b2a91466511f60e33e2e77fed2bf9c60bc31803d.tar.gz |
node: Add 'get_str_list' on 'MappingNode'
`mapping.get_sequence(...).as_str_list()` is a very common
pattern seen both in plugins and the core. Adding a helper to reduce
the number of operations will make usage smoother
Diffstat (limited to 'tests')
-rw-r--r-- | tests/format/include.py | 4 | ||||
-rw-r--r-- | tests/format/include_composition.py | 16 | ||||
-rw-r--r-- | tests/format/projectoverrides.py | 2 | ||||
-rw-r--r-- | tests/frontend/project/sources/fetch_source.py | 2 | ||||
-rw-r--r-- | tests/internals/yaml.py | 6 |
5 files changed, 15 insertions, 15 deletions
diff --git a/tests/format/include.py b/tests/format/include.py index 8902aa3eb..434a94d1f 100644 --- a/tests/format/include.py +++ b/tests/format/include.py @@ -197,7 +197,7 @@ def test_include_element_overrides_composition(cli, datafiles): 'element.bst']) result.assert_success() loaded = _yaml.load_data(result.output) - assert loaded.get_sequence('build-commands').as_str_list() == ['first', 'second'] + assert loaded.get_str_list('build-commands') == ['first', 'second'] @pytest.mark.datafiles(DATA_DIR) @@ -215,7 +215,7 @@ def test_list_overide_does_not_fail_upon_first_composition(cli, datafiles): # Assert that the explicitly overwritten public data is present bst = loaded.get_mapping('bst') assert 'foo-commands' in bst - assert bst.get_sequence('foo-commands').as_str_list() == ['need', 'this'] + assert bst.get_str_list('foo-commands') == ['need', 'this'] @pytest.mark.datafiles(DATA_DIR) diff --git a/tests/format/include_composition.py b/tests/format/include_composition.py index ec48d82a2..e10e28bc0 100644 --- a/tests/format/include_composition.py +++ b/tests/format/include_composition.py @@ -30,7 +30,7 @@ def test_main_has_priority(tmpdir): includes.process(main) - assert main.get_sequence('test').as_str_list() == ['main'] + assert main.get_str_list('test') == ['main'] def test_include_cannot_append(tmpdir): @@ -45,7 +45,7 @@ def test_include_cannot_append(tmpdir): includes.process(main) - assert main.get_sequence('test').as_str_list() == ['main'] + assert main.get_str_list('test') == ['main'] def test_main_can_append(tmpdir): @@ -59,7 +59,7 @@ def test_main_can_append(tmpdir): includes.process(main) - assert main.get_sequence('test').as_str_list() == ['a', 'main'] + assert main.get_str_list('test') == ['a', 'main'] def test_sibling_cannot_append_backward(tmpdir): @@ -76,7 +76,7 @@ def test_sibling_cannot_append_backward(tmpdir): includes.process(main) - assert main.get_sequence('test').as_str_list() == ['b'] + assert main.get_str_list('test') == ['b'] def test_sibling_can_append_forward(tmpdir): @@ -93,7 +93,7 @@ def test_sibling_can_append_forward(tmpdir): includes.process(main) - assert main.get_sequence('test').as_str_list() == ['a', 'b'] + assert main.get_str_list('test') == ['a', 'b'] def test_lastest_sibling_has_priority(tmpdir): @@ -110,7 +110,7 @@ def test_lastest_sibling_has_priority(tmpdir): includes.process(main) - assert main.get_sequence('test').as_str_list() == ['b'] + assert main.get_str_list('test') == ['b'] def test_main_keeps_keys(tmpdir): @@ -124,7 +124,7 @@ def test_main_keeps_keys(tmpdir): includes.process(main) - assert main.get_sequence('test').as_str_list() == ['a'] + assert main.get_str_list('test') == ['a'] assert main.get_str('something') == 'else' @@ -147,5 +147,5 @@ def test_overwrite_directive_on_later_composite(tmpdir): includes.process(main) - assert main.get_sequence('test').as_str_list() == ['Overwritten'] + assert main.get_str_list('test') == ['Overwritten'] assert main.get_str('foo') == 'should be present' diff --git a/tests/format/projectoverrides.py b/tests/format/projectoverrides.py index 730e43b1e..7932ffb4a 100644 --- a/tests/format/projectoverrides.py +++ b/tests/format/projectoverrides.py @@ -24,6 +24,6 @@ def test_prepend_configure_commands(cli, datafiles): result.assert_success() loaded = _yaml.load_data(result.output) - config_commands = loaded.get_sequence('configure-commands').as_str_list() + config_commands = loaded.get_str_list('configure-commands') assert len(config_commands) == 3 assert config_commands[0] == 'echo "Hello World!"' diff --git a/tests/frontend/project/sources/fetch_source.py b/tests/frontend/project/sources/fetch_source.py index ead5bc3f5..ac3020ec2 100644 --- a/tests/frontend/project/sources/fetch_source.py +++ b/tests/frontend/project/sources/fetch_source.py @@ -38,7 +38,7 @@ class FetchFetcher(SourceFetcher): class FetchSource(Source): # Read config to know which URLs to fetch def configure(self, node): - self.original_urls = node.get_sequence('urls').as_str_list() + self.original_urls = node.get_str_list('urls') self.output_file = node.get_str('output-text') self.fetch_succeeds = { key: value.as_bool() diff --git a/tests/internals/yaml.py b/tests/internals/yaml.py index d94d006e3..93619dc4c 100644 --- a/tests/internals/yaml.py +++ b/tests/internals/yaml.py @@ -146,7 +146,7 @@ def test_node_set_overwrite(datafiles): assert base.get_str('kind') == 'cow' # Overwrite a list as a string - assert base.get_sequence('moods').as_str_list() == ['happy', 'sad'] + assert base.get_str_list('moods') == ['happy', 'sad'] base['moods'] = 'unemotional' assert base.get_str('moods') == 'unemotional' @@ -160,10 +160,10 @@ def test_node_set_list_element(datafiles): base = _yaml.load(filename) - assert base.get_sequence('moods').as_str_list() == ['happy', 'sad'] + assert base.get_str_list('moods') == ['happy', 'sad'] base.get_sequence('moods')[0] = 'confused' - assert base.get_sequence('moods').as_str_list() == ['confused', 'sad'] + assert base.get_str_list('moods') == ['confused', 'sad'] # Really this is testing _yaml.node_copy(), we want to |