summaryrefslogtreecommitdiff
path: root/contrib/python/test
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2018-05-25 15:18:43 -0700
committerJhon Honce <jhonce@redhat.com>2018-05-31 20:13:35 -0700
commit2cb881fa58a6a8fe6c89ec2885f01ebb3d74d871 (patch)
tree4cca7b43b7e7e7ab1bff0687d846f2cc6e6540c7 /contrib/python/test
parenta9e9fd4f5b56f0dd91944b86feba9a2d3814d93e (diff)
downloadpodman-2cb881fa58a6a8fe6c89ec2885f01ebb3d74d871.tar.gz
podman-2cb881fa58a6a8fe6c89ec2885f01ebb3d74d871.tar.bz2
podman-2cb881fa58a6a8fe6c89ec2885f01ebb3d74d871.zip
Implement container attach
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'contrib/python/test')
-rw-r--r--contrib/python/test/podman_testcase.py3
-rw-r--r--contrib/python/test/test_containers.py20
2 files changed, 18 insertions, 5 deletions
diff --git a/contrib/python/test/podman_testcase.py b/contrib/python/test/podman_testcase.py
index fc99f26ce..f96a3a013 100644
--- a/contrib/python/test/podman_testcase.py
+++ b/contrib/python/test/podman_testcase.py
@@ -62,7 +62,8 @@ class PodmanTestCase(unittest.TestCase):
cmd = ['podman']
cmd.extend(podman_args)
- cmd.extend(['run', '-d', 'alpine', 'sleep', '500'])
+ # cmd.extend(['run', '-d', 'alpine', 'sleep', '500'])
+ cmd.extend(['run', '-dt', 'alpine', '/bin/sh'])
PodmanTestCase.alpine_process = subprocess.Popen(
cmd,
stdout=PodmanTestCase.alpine_log,
diff --git a/contrib/python/test/test_containers.py b/contrib/python/test/test_containers.py
index 5c7c9934b..87d43adb4 100644
--- a/contrib/python/test/test_containers.py
+++ b/contrib/python/test/test_containers.py
@@ -1,11 +1,9 @@
import os
import signal
-import time
import unittest
from test.podman_testcase import PodmanTestCase
import podman
-from podman import datetime_parse
class TestContainers(PodmanTestCase):
@@ -65,8 +63,22 @@ class TestContainers(PodmanTestCase):
self.pclient.containers.get("bozo")
def test_attach(self):
- with self.assertRaisesNotImplemented():
- self.alpine_ctnr.attach()
+ # StringIO does not support fileno() so we had to go old school
+ input = os.path.join(self.tmpdir, 'test_attach.stdin')
+ output = os.path.join(self.tmpdir, 'test_attach.stdout')
+
+ with open(input, 'w+') as mock_in, open(output, 'w+') as mock_out:
+ # double quote is indeed in the expected place
+ 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())
+
+ mock_out.flush()
+ mock_out.seek(0, 0)
+ output = mock_out.read()
+ self.assertIn('Hello', output)
def test_processes(self):
actual = list(self.alpine_ctnr.processes())