Refactor attach()/start() after podman changes

* Update examples
* Update/Clean up unittests
* Add Mixins for container attach()/start()

Signed-off-by: Jhon Honce <jhonce@redhat.com>

Closes: #1080
Approved by: baude
This commit is contained in:
Jhon Honce
2018-07-10 12:12:59 -07:00
committed by Atomic Bot
parent 7f3f491396
commit 86154b6538
7 changed files with 132 additions and 90 deletions

View File

@ -72,14 +72,18 @@ class TestContainers(PodmanTestCase):
mock_in.write('echo H"ello, World"; exit\n')
mock_in.seek(0, 0)
self.alpine_ctnr.attach(
stdin=mock_in.fileno(), stdout=mock_out.fileno())
ctnr = self.pclient.images.get(self.alpine_ctnr.image).container(
detach=True, tty=True)
ctnr.attach(stdin=mock_in.fileno(), stdout=mock_out.fileno())
ctnr.start()
mock_out.flush()
mock_out.seek(0, 0)
output = mock_out.read()
self.assertIn('Hello', output)
ctnr.remove(force=True)
def test_processes(self):
actual = list(self.alpine_ctnr.processes())
self.assertGreaterEqual(len(actual), 2)
@ -133,8 +137,7 @@ class TestContainers(PodmanTestCase):
def test_commit(self):
# TODO: Test for STOPSIGNAL when supported by OCI
# TODO: Test for message when supported by OCI
details = self.pclient.images.get(
self.alpine_ctnr.inspect().image).inspect()
details = self.pclient.images.get(self.alpine_ctnr.image).inspect()
changes = ['ENV=' + i for i in details.containerconfig['env']]
changes.append('CMD=/usr/bin/zsh')
changes.append('ENTRYPOINT=/bin/sh date')

View File

@ -62,6 +62,7 @@ class TestImages(PodmanTestCase):
actual = self.alpine_image.container()
self.assertIsNotNone(actual)
self.assertEqual(actual.status, 'configured')
ctnr = actual.start()
self.assertIn(ctnr.status, ['running', 'exited'])