tests: move stub tools, into subdir, import docker_test.

issue260
David Wilson 6 years ago
parent 7647c95f34
commit 73055150f3

@ -119,7 +119,7 @@ class CallFunctionTest(testlib.RouterMixin, testlib.TestCase):
lambda: recv.get().unpickle())
class ChainTest(testlib.RouterMixin, testlib.TestCase):
class CallChainTest(testlib.RouterMixin, testlib.TestCase):
# Verify mitogen_chain functionality.
klass = mitogen.parent.CallChain

@ -0,0 +1,5 @@
# stubs/
Dummy implementations of various third party tools that just spawn local Python
interpreters. Used to roughly test the tools' associated Mitogen classes.

@ -0,0 +1,7 @@
#!/usr/bin/env python
import sys
import os
os.environ['ORIGINAL_ARGV'] = repr(sys.argv)
os.execv(sys.executable, sys.argv[sys.argv.index('-c') - 1:])

@ -0,0 +1,28 @@
import os
import mitogen
import unittest2
import testlib
class ConstructorTest(testlib.RouterMixin, unittest2.TestCase):
def test_okay(self):
docker_path = testlib.data_path('stubs/docker.py')
context = self.router.docker(
container='container_name',
docker_path=docker_path,
)
stream = self.router.stream_by_id(context.context_id)
argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
self.assertEquals(argv[0], docker_path)
self.assertEquals(argv[1], 'exec')
self.assertEquals(argv[2], '--interactive')
self.assertEquals(argv[3], 'container_name')
self.assertEquals(argv[4], stream.python_path)
if __name__ == '__main__':
unittest2.main()

@ -11,9 +11,9 @@ def has_subseq(seq, subseq):
return any(seq[x:x+len(subseq)] == subseq for x in range(0, len(seq)))
class FakeLxcAttachTest(testlib.RouterMixin, unittest2.TestCase):
class ConstructorTest(testlib.RouterMixin, unittest2.TestCase):
def test_okay(self):
lxc_attach_path = testlib.data_path('fake_lxc_attach.py')
lxc_attach_path = testlib.data_path('stubs/lxc-attach.py')
context = self.router.lxc(
container='container_name',
lxc_attach_path=lxc_attach_path,

@ -7,9 +7,9 @@ import unittest2
import testlib
class FakeLxcTest(testlib.RouterMixin, unittest2.TestCase):
class ConstructorTest(testlib.RouterMixin, unittest2.TestCase):
def test_okay(self):
lxc_path = testlib.data_path('fake_lxc.py')
lxc_path = testlib.data_path('stubs/lxc.py')
context = self.router.lxd(
container='container_name',
lxc_path=lxc_path,

@ -11,12 +11,12 @@ import testlib
import plain_old_module
class FakeSshTest(testlib.RouterMixin, unittest2.TestCase):
class ConstructorTest(testlib.RouterMixin, unittest2.TestCase):
def test_okay(self):
context = self.router.ssh(
hostname='hostname',
username='mitogen__has_sudo',
ssh_path=testlib.data_path('fakessh.py'),
ssh_path=testlib.data_path('stubs/ssh.py'),
)
#context.call(mitogen.utils.log_to_file, '/tmp/log')
#context.call(mitogen.utils.disable_site_packages)

Loading…
Cancel
Save