diff options
author | James Ennis <james.ennis@codethink.co.uk> | 2019-06-17 14:12:27 +0100 |
---|---|---|
committer | James Ennis <james.ennis@codethink.com> | 2019-06-26 08:36:20 +0000 |
commit | 1c0bf810c6e5c8e01e9213acafb7079c8ce814a1 (patch) | |
tree | 07953d65d5073637c9974a7b710379cc210cc222 /tests/testutils | |
parent | 956cd6d4485e30a9f39c7a1e44bf9fdc47392e3e (diff) | |
download | buildstream-1c0bf810c6e5c8e01e9213acafb7079c8ce814a1.tar.gz |
testutils: Move assert_shared and assert_not_shared to testutils
Diffstat (limited to 'tests/testutils')
-rw-r--r-- | tests/testutils/__init__.py | 2 | ||||
-rw-r--r-- | tests/testutils/artifactshare.py | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/tests/testutils/__init__.py b/tests/testutils/__init__.py index 2e1f72138..9a904f007 100644 --- a/tests/testutils/__init__.py +++ b/tests/testutils/__init__.py @@ -23,7 +23,7 @@ # William Salmon <will.salmon@codethink.co.uk> # -from .artifactshare import create_artifact_share +from .artifactshare import create_artifact_share, assert_shared, assert_not_shared from .element_generators import create_element_size, update_element_size from .junction import generate_junction from .runner_integration import wait_for_cache_granularity diff --git a/tests/testutils/artifactshare.py b/tests/testutils/artifactshare.py index bc69a87d8..a5522c8eb 100644 --- a/tests/testutils/artifactshare.py +++ b/tests/testutils/artifactshare.py @@ -207,3 +207,19 @@ def create_artifact_share(directory, *, total_space=None, free_space=None, statvfs_result = namedtuple('statvfs_result', 'f_blocks f_bfree f_bsize f_bavail') + + +# Assert that a given artifact is in the share +# +def assert_shared(cli, share, project, element_name, *, project_name='test'): + if not share.has_artifact(cli.get_artifact_name(project, project_name, element_name)): + raise AssertionError("Artifact share at {} does not contain the expected element {}" + .format(share.repo, element_name)) + + +# Assert that a given artifact is not in the share +# +def assert_not_shared(cli, share, project, element_name, *, project_name='test'): + if share.has_artifact(cli.get_artifact_name(project, project_name, element_name)): + raise AssertionError("Artifact share at {} unexpectedly contains the element {}" + .format(share.repo, element_name)) |