diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-01-20 12:52:16 -0500 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-01-24 13:02:08 -0500 |
commit | 9fd9fbb99fe54fda7599c39c014727a157c9ee2a (patch) | |
tree | 0c8bafddc0303072bce75872c9867d0f44598ef1 /tests | |
parent | 24ca2f469230a2b9a1ce6a487f1341b4428d4477 (diff) | |
download | buildstream-9fd9fbb99fe54fda7599c39c014727a157c9ee2a.tar.gz |
_artifactcache.py: Refactored to use utils._get_volume_size()
This will benefit from a better UtilError being raised, and
and turns the artifact cache's local function into a one liner.
The loop which finds the first existing directory in the
given path has been removed, being meaningless due to the
call to os.makedirs() in ArtifactCache.__init__().
The local function was renamed to _get_cache_volume_size() and
no longer takes any arguments, which is more suitable for the
function as it serves as a testing override surface for
unittest.mock().
The following test cases which use the function to override
the ArtifactCache behavior have been updated to use the new
overridable function name:
tests/artifactcache/cache_size.py
tests/artifactcache/expiry.py
Diffstat (limited to 'tests')
-rw-r--r-- | tests/artifactcache/cache_size.py | 2 | ||||
-rw-r--r-- | tests/artifactcache/expiry.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/tests/artifactcache/cache_size.py b/tests/artifactcache/cache_size.py index 11c8f6194..63ab9ad07 100644 --- a/tests/artifactcache/cache_size.py +++ b/tests/artifactcache/cache_size.py @@ -80,7 +80,7 @@ def test_quota_over_1024T(cli, tmpdir): _yaml.dump({'name': 'main'}, str(project.join("project.conf"))) volume_space_patch = mock.patch( - "buildstream._artifactcache.ArtifactCache._get_volume_space_info_for", + "buildstream._artifactcache.ArtifactCache._get_cache_volume_size", autospec=True, return_value=(1025 * TiB, 1025 * TiB) ) diff --git a/tests/artifactcache/expiry.py b/tests/artifactcache/expiry.py index d7bafe7e8..2230b70bd 100644 --- a/tests/artifactcache/expiry.py +++ b/tests/artifactcache/expiry.py @@ -358,9 +358,9 @@ def test_invalid_cache_quota(cli, datafiles, tmpdir, quota, err_domain, err_reas total_space = 10000 volume_space_patch = mock.patch( - "buildstream._artifactcache.ArtifactCache._get_volume_space_info_for", + "buildstream._artifactcache.ArtifactCache._get_cache_volume_size", autospec=True, - return_value=(free_space, total_space), + return_value=(total_space, free_space), ) cache_size_patch = mock.patch( |