diff options
author | Lachlan Mackenzie <lachlan.mackenzie@codethink.co.uk> | 2018-10-12 11:13:21 +0100 |
---|---|---|
committer | Lachlan Mackenzie <lachlan.mackenzie@codethink.co.uk> | 2018-10-12 12:44:57 +0100 |
commit | 40f838abe30f8bb9990cfa9458e780ef89b1671d (patch) | |
tree | b4d7f4a2972f445976531afbc430aeed096efd52 | |
parent | b8939e3f9abb9c3640a3817247c72af29acbbf0e (diff) | |
download | buildstream-lachlan/pickle-yaml-test-list-composite.tar.gz |
Add YAML cache changed file testlachlan/pickle-yaml-test-list-composite
* Test in same style as test_yamlcache_used
* Move of project not required so removed
-rw-r--r-- | tests/frontend/yamlcache.py | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/tests/frontend/yamlcache.py b/tests/frontend/yamlcache.py index 0bcc423ec..7b03c70cc 100644 --- a/tests/frontend/yamlcache.py +++ b/tests/frontend/yamlcache.py @@ -112,8 +112,31 @@ def test_yamlcache_used(cli, tmpdir, ref_storage, with_junction, move_project): @pytest.mark.parametrize('ref_storage', ['inline', 'project.refs']) @pytest.mark.parametrize('with_junction', ['junction', 'no-junction']) -@pytest.mark.parametrize('move_project', ['move', 'no-move']) -def test_yamlcache_changed_file(cli, ref_storage, with_junction, move_project): +def test_yamlcache_changed_file(cli, tmpdir, ref_storage, with_junction): # i.e. a file is cached, the file is changed, loading the file (with cache) returns new data # inline and junction can only be changed by opening a workspace - pass + # Generate the project + project = generate_project(str(tmpdir), ref_storage, with_junction) + if with_junction == 'junction': + result = cli.run(project=project, args=['fetch', '--track', 'junction.bst']) + result.assert_success() + + # bst show to put it in the cache + result = cli.run(project=project, args=['show', 'test.bst']) + result.assert_success() + + element_path = os.path.join(project, 'elements', 'test.bst') + with with_yamlcache(project) as (yc, prj): + # Check that it's in the cache then modify + assert yc.is_cached(prj, element_path) + with open(element_path, "a") as f: + f.write('\nvariables: {modified: True}\n') + # Load modified yaml cache file into cache + _yaml.load(element_path, copy_tree=False, project=prj, yaml_cache=yc) + + # Show that a variable has been added + result = cli.run(project=project, args=['show', '--format', '%{vars}', 'test.bst']) + result.assert_success() + data = yaml.safe_load(result.output) + assert 'modified' in data + assert data['modified'] == 'True' |