summaryrefslogtreecommitdiff
path: root/contrib/python/test/test_tunnel.py
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2018-07-12 19:26:14 -0700
committerJhon Honce <jhonce@redhat.com>2018-07-13 12:50:12 -0700
commit74ccd9ce5f29a1df4ffe70b4d8bd00c29d5d9d15 (patch)
tree75ba256d70545d79aa61d7c57c20df886be1555f /contrib/python/test/test_tunnel.py
parent44b523c946c88e540b50d7ba59f441b5f8e0bad0 (diff)
downloadpodman-74ccd9ce5f29a1df4ffe70b4d8bd00c29d5d9d15.tar.gz
podman-74ccd9ce5f29a1df4ffe70b4d8bd00c29d5d9d15.tar.bz2
podman-74ccd9ce5f29a1df4ffe70b4d8bd00c29d5d9d15.zip
Update python directories to better support setup.py
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'contrib/python/test/test_tunnel.py')
-rw-r--r--contrib/python/test/test_tunnel.py79
1 files changed, 0 insertions, 79 deletions
diff --git a/contrib/python/test/test_tunnel.py b/contrib/python/test/test_tunnel.py
deleted file mode 100644
index 2522df0ab..000000000
--- a/contrib/python/test/test_tunnel.py
+++ /dev/null
@@ -1,79 +0,0 @@
-from __future__ import absolute_import
-
-import time
-import unittest
-from unittest.mock import MagicMock, patch
-
-import podman
-from podman.libs.tunnel import Context, Portal, Tunnel
-
-
-class TestTunnel(unittest.TestCase):
- def setUp(self):
- self.tunnel_01 = MagicMock(spec=Tunnel)
- self.tunnel_02 = MagicMock(spec=Tunnel)
-
- def test_portal_ops(self):
- portal = Portal(sweap=500)
- portal['unix:/01'] = self.tunnel_01
- portal['unix:/02'] = self.tunnel_02
-
- self.assertEqual(portal.get('unix:/01'), self.tunnel_01)
- self.assertEqual(portal.get('unix:/02'), self.tunnel_02)
-
- del portal['unix:/02']
- with self.assertRaises(KeyError):
- portal['unix:/02']
- self.assertEqual(len(portal), 1)
-
- def test_portal_reaping(self):
- portal = Portal(sweap=0.5)
- portal['unix:/01'] = self.tunnel_01
- portal['unix:/02'] = self.tunnel_02
-
- self.assertEqual(len(portal), 2)
- for entry in portal:
- self.assertIn(entry, (self.tunnel_01, self.tunnel_02))
-
- time.sleep(1)
- portal.reap()
- self.assertEqual(len(portal), 0)
-
- def test_portal_no_reaping(self):
- portal = Portal(sweap=500)
- portal['unix:/01'] = self.tunnel_01
- portal['unix:/02'] = self.tunnel_02
-
- portal.reap()
- self.assertEqual(len(portal), 2)
- for entry in portal:
- self.assertIn(entry, (self.tunnel_01, self.tunnel_02))
-
- @patch('subprocess.Popen')
- @patch('os.path.exists', return_value=True)
- @patch('weakref.finalize')
- def test_tunnel(self, mock_finalize, mock_exists, mock_Popen):
- context = Context(
- 'unix:/01',
- 'io.projectatomic.podman',
- '/tmp/user/socket',
- '/run/podman/socket',
- 'user',
- 'hostname',
- '~/.ssh/id_rsa',
- )
- tunnel = Tunnel(context).bore('unix:/01')
-
- cmd = [
- 'ssh',
- '-nNTq',
- '-L',
- '{}:{}'.format(context.local_socket, context.remote_socket),
- '-i',
- context.identity_file,
- 'ssh://{}@{}'.format(context.username, context.hostname),
- ]
-
- mock_finalize.assert_called_once_with(tunnel, tunnel.close, 'unix:/01')
- mock_exists.assert_called_once_with(context.local_socket)
- mock_Popen.assert_called_once_with(cmd, close_fds=True)