diff options
author | Benjamin Schubert <contact@benschubert.me> | 2019-10-09 14:48:17 +0100 |
---|---|---|
committer | Benjamin Schubert <contact@benschubert.me> | 2019-10-10 09:47:50 +0000 |
commit | c6b35598cff3b580dcce6ce81581e9b2a758cf00 (patch) | |
tree | 5154d1785e4c23138b2456ced645e3e6db60e539 | |
parent | e31b22a39e3f127685be50cd5a56217a8c11b07d (diff) | |
download | buildstream-c6b35598cff3b580dcce6ce81581e9b2a758cf00.tar.gz |
tests/sourcecache/fetch.py: Extract logic to move local cas to remote
This method can be reused and shared, and makes the tests more readable.
-rw-r--r-- | tests/sourcecache/fetch.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/tests/sourcecache/fetch.py b/tests/sourcecache/fetch.py index 99c00f120..1571300fb 100644 --- a/tests/sourcecache/fetch.py +++ b/tests/sourcecache/fetch.py @@ -34,6 +34,14 @@ from tests.testutils import create_artifact_share, dummy_context DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project") +def move_local_cas_to_remote_source_share(local, remote): + shutil.rmtree(os.path.join(remote, 'repo', 'cas')) + shutil.move(os.path.join(local, 'source_protos'), os.path.join(remote, 'repo')) + shutil.move(os.path.join(local, 'cas'), os.path.join(remote, 'repo')) + shutil.rmtree(os.path.join(local, 'sources')) + shutil.rmtree(os.path.join(local, 'artifacts')) + + @pytest.mark.datafiles(DATA_DIR) def test_source_fetch(cli, tmpdir, datafiles): project_dir = str(datafiles) @@ -86,16 +94,7 @@ def test_source_fetch(cli, tmpdir, datafiles): sourcecache = context.sourcecache digest = sourcecache.export(source)._get_digest() - # Move source in local cas to repo - shutil.rmtree(os.path.join(str(tmpdir), 'sourceshare', 'repo', 'cas')) - shutil.move( - os.path.join(str(tmpdir), 'cache', 'source_protos'), - os.path.join(str(tmpdir), 'sourceshare', 'repo')) - shutil.move( - os.path.join(str(tmpdir), 'cache', 'cas'), - os.path.join(str(tmpdir), 'sourceshare', 'repo')) - shutil.rmtree(os.path.join(str(tmpdir), 'cache', 'sources')) - shutil.rmtree(os.path.join(str(tmpdir), 'cache', 'artifacts')) + move_local_cas_to_remote_source_share(str(cache_dir), share.directory) # check the share has the object assert share.has_object(digest) |