diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-11-11 16:47:05 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-11-12 15:13:09 -0700 |
commit | a1187ee6f3a85f8d4e68717731b7b9e2163e8f25 (patch) | |
tree | 76617b969d1f8c2069c0492f1d7c4ea117cfc9ce /test/python/docker/__init__.py | |
parent | a65ecc70c21eb5eef7d7a6b70cc1f90e577bb72e (diff) | |
download | podman-a1187ee6f3a85f8d4e68717731b7b9e2163e8f25.tar.gz podman-a1187ee6f3a85f8d4e68717731b7b9e2163e8f25.tar.bz2 podman-a1187ee6f3a85f8d4e68717731b7b9e2163e8f25.zip |
Refactor to use DockerClient vs APIClient
* Update tests and framework
* remove tests for APIClient methods
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'test/python/docker/__init__.py')
-rw-r--r-- | test/python/docker/__init__.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/test/python/docker/__init__.py b/test/python/docker/__init__.py index 0e10676b9..316b102f4 100644 --- a/test/python/docker/__init__.py +++ b/test/python/docker/__init__.py @@ -6,6 +6,8 @@ import shutil import subprocess import tempfile +from docker import DockerClient + from test.python.docker import constant @@ -141,16 +143,15 @@ class Podman(object): def tear_down(self): shutil.rmtree(self.anchor_directory, ignore_errors=True) - def restore_image_from_cache(self, client): - img = os.path.join(self.image_cache, constant.ALPINE_TARBALL) - if not os.path.exists(img): - client.pull(constant.ALPINE) - image = client.get_image(constant.ALPINE) - with open(img, mode="wb") as tarball: - for frame in image: + def restore_image_from_cache(self, client: DockerClient): + path = os.path.join(self.image_cache, constant.ALPINE_TARBALL) + if not os.path.exists(path): + img = client.images.pull(constant.ALPINE) + with open(path, mode="wb") as tarball: + for frame in img.save(named=True): tarball.write(frame) else: - self.run("load", "-i", img, check=True) + self.run("load", "-i", path, check=True) def flush_image_cache(self): for f in pathlib.Path(self.image_cache).glob("*.tar"): |