summaryrefslogtreecommitdiff
path: root/test/python/docker/common.py
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-11-11 16:47:05 -0700
committerJhon Honce <jhonce@redhat.com>2020-11-12 15:13:09 -0700
commita1187ee6f3a85f8d4e68717731b7b9e2163e8f25 (patch)
tree76617b969d1f8c2069c0492f1d7c4ea117cfc9ce /test/python/docker/common.py
parenta65ecc70c21eb5eef7d7a6b70cc1f90e577bb72e (diff)
downloadpodman-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/common.py')
-rw-r--r--test/python/docker/common.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/test/python/docker/common.py b/test/python/docker/common.py
index 2828d2d20..e79d64a9b 100644
--- a/test/python/docker/common.py
+++ b/test/python/docker/common.py
@@ -1,21 +1,23 @@
-from docker import APIClient
+from docker import DockerClient
from test.python.docker import constant
-def run_top_container(client: APIClient):
- c = client.create_container(
+def run_top_container(client: DockerClient):
+ c = client.containers.create(
constant.ALPINE, command="top", detach=True, tty=True, name="top"
)
- client.start(c.get("Id"))
- return c.get("Id")
+ c.start()
+ return c.id
-def remove_all_containers(client: APIClient):
- for ctnr in client.containers(quiet=True):
- client.remove_container(ctnr, force=True)
+def remove_all_containers(client: DockerClient):
+ for ctnr in client.containers.list(all=True):
+ ctnr.remove(force=True)
-def remove_all_images(client: APIClient):
- for image in client.images(quiet=True):
- client.remove_image(image, force=True)
+def remove_all_images(client: DockerClient):
+ for img in client.images.list():
+ # FIXME should DELETE /images accept the sha256: prefix?
+ id_ = img.id.removeprefix("sha256:")
+ client.images.remove(id_, force=True)