diff --git a/tests/buildah_test.py b/tests/buildah_test.py new file mode 100644 index 00000000..dad2534f --- /dev/null +++ b/tests/buildah_test.py @@ -0,0 +1,28 @@ +import os + +import mitogen + +import unittest2 + +import testlib + + +class ConstructorTest(testlib.RouterMixin, testlib.TestCase): + def test_okay(self): + buildah_path = testlib.data_path('stubs/stub-buildah.py') + context = self.router.buildah( + container='container_name', + buildah_path=buildah_path, + ) + stream = self.router.stream_by_id(context.context_id) + + argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV')) + self.assertEquals(argv[0], buildah_path) + self.assertEquals(argv[1], 'run') + self.assertEquals(argv[2], '--') + self.assertEquals(argv[3], 'container_name') + self.assertEquals(argv[4], stream.python_path) + + +if __name__ == '__main__': + unittest2.main() diff --git a/tests/data/stubs/stub-buildah.py b/tests/data/stubs/stub-buildah.py new file mode 100755 index 00000000..558f117a --- /dev/null +++ b/tests/data/stubs/stub-buildah.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +import sys +import os + +os.environ['ORIGINAL_ARGV'] = repr(sys.argv) +os.environ['THIS_IS_STUB_BUILDAH'] = '1' +os.execv(sys.executable, sys.argv[sys.argv.index('--') + 2:])