summaryrefslogtreecommitdiff
path: root/test/dockerpy/images.py
diff options
context:
space:
mode:
authorSujil02 <sushah@redhat.com>2020-06-07 22:25:31 -0400
committerSujil02 <sushah@redhat.com>2020-06-07 22:27:01 -0400
commit37428df4c2ea947a0ae663da5196eb17a8c6c040 (patch)
tree6d67cf6c02233068b9128faa1ad817491517df62 /test/dockerpy/images.py
parent1fcb6788a5d7471a7ca6215a40e36e21812a0f6e (diff)
downloadpodman-37428df4c2ea947a0ae663da5196eb17a8c6c040.tar.gz
podman-37428df4c2ea947a0ae663da5196eb17a8c6c040.tar.bz2
podman-37428df4c2ea947a0ae663da5196eb17a8c6c040.zip
Modify py test to start stop system service for each test
Start stop system service for each test class to make it east to integrate to CI Adds more tests Add some common methods shared between images and containers test. Signed-off-by: Sujil02 <sushah@redhat.com>
Diffstat (limited to 'test/dockerpy/images.py')
-rw-r--r--test/dockerpy/images.py40
1 files changed, 30 insertions, 10 deletions
diff --git a/test/dockerpy/images.py b/test/dockerpy/images.py
index 07ea6c0f8..1e07d25c7 100644
--- a/test/dockerpy/images.py
+++ b/test/dockerpy/images.py
@@ -11,19 +11,29 @@ client = common.get_client()
class TestImages(unittest.TestCase):
+ podman = None
def setUp(self):
super().setUp()
client.pull(constant.ALPINE)
def tearDown(self):
- allImages = client.images()
- for image in allImages:
- client.remove_image(image,force=True)
+ common.remove_all_images()
return super().tearDown()
-# Inspect Image
+ @classmethod
+ def setUpClass(cls):
+ super().setUpClass()
+ common.enable_sock(cls)
+
+
+ @classmethod
+ def tearDownClass(cls):
+ common.terminate_connection(cls)
+ return super().tearDownClass()
+# Inspect Image
+
def test_inspect_image(self):
# Check for error with wrong image name
with self.assertRaises(requests.HTTPError):
@@ -79,8 +89,8 @@ class TestImages(unittest.TestCase):
for i in response:
# Alpine found
if "docker.io/library/alpine" in i["Name"]:
- self.assertTrue(True, msg="Image found")
- self.assertFalse(False,msg="Image not found")
+ self.assertTrue
+ self.assertFalse
# Image Exist (No docker-py support yet)
@@ -105,19 +115,22 @@ class TestImages(unittest.TestCase):
alpine_image = client.inspect_image(constant.ALPINE)
for h in imageHistory:
if h["Id"] in alpine_image["Id"]:
- self.assertTrue(True,msg="Image History validated")
- self.assertFalse(False,msg="Unable to get image history")
+ self.assertTrue
+ self.assertFalse
# Prune Image (No docker-py support yet)
# Export Image
def test_export_image(self):
- file = "/tmp/alpine-latest.tar"
+ client.pull(constant.BB)
+ file = os.path.join(constant.ImageCacheDir , "busybox.tar")
+ if not os.path.exists(constant.ImageCacheDir):
+ os.makedirs(constant.ImageCacheDir)
# Check for error with wrong image name
with self.assertRaises(requests.HTTPError):
client.get_image("dummy")
- response = client.get_image(constant.ALPINE)
+ response = client.get_image(constant.BB)
image_tar = open(file,mode="wb")
image_tar.write(response.data)
image_tar.close()
@@ -125,6 +138,13 @@ class TestImages(unittest.TestCase):
# Import|Load Image
+ def test_import_image(self):
+ allImages = client.images()
+ self.assertEqual(len(allImages), 1)
+ file = os.path.join(constant.ImageCacheDir , "busybox.tar")
+ client.import_image_from_file(filename=file)
+ allImages = client.images()
+ self.assertEqual(len(allImages), 2)
if __name__ == '__main__':
# Setup temporary space