From 1c0bf810c6e5c8e01e9213acafb7079c8ce814a1 Mon Sep 17 00:00:00 2001 From: James Ennis Date: Mon, 17 Jun 2019 14:12:27 +0100 Subject: testutils: Move assert_shared and assert_not_shared to testutils --- tests/testutils/__init__.py | 2 +- tests/testutils/artifactshare.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'tests/testutils') 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 # -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)) -- cgit v1.2.1