issue #409: add kubectl stub and constructor test.

This commit is contained in:
David Wilson 2018-10-31 00:46:47 +00:00
parent c51b67b863
commit 429832b8f7
2 changed files with 37 additions and 0 deletions

View File

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

29
tests/kubectl_test.py Normal file
View File

@ -0,0 +1,29 @@
import os
import mitogen
import mitogen.parent
import unittest2
import testlib
class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
kubectl_path = testlib.data_path('stubs/stub-kubectl.py')
def test_okay(self):
context = self.router.kubectl(
pod='pod_name',
kubectl_path=self.kubectl_path
)
argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
self.assertEquals(argv[0], self.kubectl_path)
self.assertEquals(argv[1], 'exec')
self.assertEquals(argv[2], '-it')
self.assertEquals(argv[3], 'pod_name')
if __name__ == '__main__':
unittest2.main()