diff options
| author | Joffrey F <joffrey@docker.com> | 2018-04-25 16:29:41 -0700 |
|---|---|---|
| committer | Joffrey F <f.joffrey@gmail.com> | 2018-04-25 17:55:16 -0700 |
| commit | cc953cf8bf2049493c2eab252fd9fe22de8af62b (patch) | |
| tree | 4517a9abbda154ae6517fe8204b4a6b31e962907 | |
| parent | f2c1ae37dd7eca4dde9054178388aec6b15c5229 (diff) | |
| download | docker-py-cc953cf8bf2049493c2eab252fd9fe22de8af62b.tar.gz | |
prune_builds test
Signed-off-by: Joffrey F <joffrey@docker.com>
| -rw-r--r-- | docker/api/build.py | 33 | ||||
| -rw-r--r-- | tests/integration/api_build_test.py | 6 |
2 files changed, 23 insertions, 16 deletions
diff --git a/docker/api/build.py b/docker/api/build.py index 3d83b98..f62a731 100644 --- a/docker/api/build.py +++ b/docker/api/build.py @@ -264,6 +264,23 @@ class BuildApiMixin(object): return self._stream_helper(response, decode=decode) + @utils.minimum_version('1.31') + def prune_builds(self): + """ + Delete the builder cache + + Returns: + (dict): A dictionary containing information about the operation's + result. The ``SpaceReclaimed`` key indicates the amount of + bytes of disk space reclaimed. + + Raises: + :py:class:`docker.errors.APIError` + If the server returns an error. + """ + url = self._url("/build/prune") + return self._result(self._post(url), True) + def _set_auth_headers(self, headers): log.debug('Looking for auth config') @@ -305,22 +322,6 @@ class BuildApiMixin(object): else: log.debug('No auth config found') - @utils.minimum_version('1.31') - def prune_build(self): - """ - Delete builder cache - - Returns: - (dict): A dict containing - the amount of disk space reclaimed in bytes. - - Raises: - :py:class:`docker.errors.APIError` - If the server returns an error. - """ - url = self._url("/build/prune") - return self._result(self._post(url), True) - def process_dockerfile(dockerfile, path): if not dockerfile: diff --git a/tests/integration/api_build_test.py b/tests/integration/api_build_test.py index 9423012..92e0062 100644 --- a/tests/integration/api_build_test.py +++ b/tests/integration/api_build_test.py @@ -503,3 +503,9 @@ class BuildTest(BaseAPIIntegrationTest): assert sorted( [b'.', b'..', b'file.txt', b'custom.dockerfile'] ) == sorted(lsdata) + + @requires_api_version('1.31') + def test_prune_builds(self): + prune_result = self.client.prune_builds() + assert 'SpaceReclaimed' in prune_result + assert isinstance(prune_result['SpaceReclaimed'], int) |
