diff options
author | Jhon Honce <jhonce@redhat.com> | 2018-06-05 12:40:35 -0700 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-06-05 21:23:54 +0000 |
commit | 93c1722caab372f873765041d2bd2b710de3c5c4 (patch) | |
tree | 3c2b5020db1e68092bbd25888a90f6ef145d0d00 /contrib/python/test/test_images.py | |
parent | 3901ecc7b6b08b7555ccf0e8a05b278b05a9629c (diff) | |
download | podman-93c1722caab372f873765041d2bd2b710de3c5c4.tar.gz podman-93c1722caab372f873765041d2bd2b710de3c5c4.tar.bz2 podman-93c1722caab372f873765041d2bd2b710de3c5c4.zip |
Add support for BuildImage
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Closes: #908
Approved by: baude
Diffstat (limited to 'contrib/python/test/test_images.py')
-rw-r--r-- | contrib/python/test/test_images.py | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/contrib/python/test/test_images.py b/contrib/python/test/test_images.py index f9eaee139..c8c1814dc 100644 --- a/contrib/python/test/test_images.py +++ b/contrib/python/test/test_images.py @@ -1,6 +1,7 @@ import itertools import os import unittest +from datetime import datetime, timezone from test.podman_testcase import PodmanTestCase import podman @@ -34,6 +35,7 @@ class TestImages(PodmanTestCase): i for i in self.images if 'docker.io/library/alpine:latest' in i['repoTags'] ] or []), None) + return self.images def test_list(self): @@ -42,15 +44,29 @@ class TestImages(PodmanTestCase): self.assertIsNotNone(self.alpine_image) def test_build(self): - with self.assertRaisesNotImplemented(): - self.pclient.images.build() + path = os.path.join(self.tmpdir, 'ctnr', 'Dockerfile') + img, logs = self.pclient.images.build( + dockerfile=[path], + tags=['alpine-unittest'], + ) + self.assertIsNotNone(img) + self.assertIn('localhost/alpine-unittest:latest', img.repoTags) + self.assertLess( + podman.datetime_parse(img.created), datetime.now(timezone.utc)) + self.assertTrue(logs) def test_create(self): + img_details = self.alpine_image.inspect() + actual = self.alpine_image.container() self.assertIsNotNone(actual) self.assertEqual(actual.status, 'configured') - cntr = actual.start() - self.assertIn(cntr.status, ['running', 'exited']) + ctnr = actual.start() + self.assertIn(ctnr.status, ['running', 'exited']) + + ctnr_details = ctnr.inspect() + for e in img_details.containerconfig['env']: + self.assertIn(e, ctnr_details.config['env']) def test_export(self): path = os.path.join(self.tmpdir, 'alpine_export.tar') @@ -60,6 +76,10 @@ class TestImages(PodmanTestCase): self.assertTrue(actual) self.assertTrue(os.path.isfile(path)) + def test_get(self): + actual = self.pclient.images.get(self.alpine_image.id) + self.assertEqual(actual, self.alpine_image) + def test_history(self): for count, record in enumerate(self.alpine_image.history()): self.assertEqual(record.id, self.alpine_image.id) @@ -102,8 +122,11 @@ class TestImages(PodmanTestCase): before = self.loadCache() # create unused image, so we have something to delete source = os.path.join(self.tmpdir, 'alpine_gold.tar') - new_img = self.pclient.images.import_image(source, 'alpine2:latest', - 'unittest.test_import') + new_img = self.pclient.images.import_image( + source, + 'alpine2:latest', + 'unittest.test_import', + ) after = self.loadCache() self.assertEqual(len(before) + 1, len(after)) |