2018-08-10 19:18:41 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
import mitogen
|
|
|
|
|
|
|
|
import unittest2
|
|
|
|
|
|
|
|
import testlib
|
|
|
|
|
|
|
|
|
|
|
|
def has_subseq(seq, subseq):
|
|
|
|
return any(seq[x:x+len(subseq)] == subseq for x in range(0, len(seq)))
|
|
|
|
|
|
|
|
|
2018-10-26 08:14:39 +00:00
|
|
|
class ConstructorTest(testlib.RouterMixin, unittest2.TestCase):
|
2018-08-10 19:18:41 +00:00
|
|
|
def test_okay(self):
|
2018-10-26 08:14:39 +00:00
|
|
|
lxc_attach_path = testlib.data_path('stubs/lxc-attach.py')
|
2018-08-10 19:18:41 +00:00
|
|
|
context = self.router.lxc(
|
|
|
|
container='container_name',
|
|
|
|
lxc_attach_path=lxc_attach_path,
|
|
|
|
)
|
|
|
|
|
|
|
|
argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
|
|
|
|
self.assertEquals(argv[0], lxc_attach_path)
|
|
|
|
self.assertTrue('--clear-env' in argv)
|
|
|
|
self.assertTrue(has_subseq(argv, ['--name', 'container_name']))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest2.main()
|