def test_timeout(self): self.expected.update(dict( timeout='10')) ctx_proxy.main(['--timeout', self.expected.get('timeout')]) self.expected.update(dict( timeout='15')) ctx_proxy.main(['-t', self.expected.get('timeout')])
def test_mixed_order(self): self.expected.update( dict(args=['1', '2', '3'], timeout='20', socket_url='mixed_socket_url')) ctx_proxy.main( ['-t', self.expected.get('timeout')] + ['--socket-url', self.expected.get('socket_url')] + self.expected.get('args')) ctx_proxy.main( ['-t', self.expected.get('timeout')] + self.expected.get('args') + ['--socket-url', self.expected.get('socket_url')]) ctx_proxy.main( self.expected.get('args') + ['-t', self.expected.get('timeout')] + ['--socket-url', self.expected.get('socket_url')])
def test_mixed_order(self): self.expected.update(dict( args=['1', '2', '3'], timeout='20', socket_url='mixed_socket_url')) ctx_proxy.main( ['-t', self.expected.get('timeout')] + ['--socket-url', self.expected.get('socket_url')] + self.expected.get('args')) ctx_proxy.main( ['-t', self.expected.get('timeout')] + self.expected.get('args') + ['--socket-url', self.expected.get('socket_url')]) ctx_proxy.main( self.expected.get('args') + ['-t', self.expected.get('timeout')] + ['--socket-url', self.expected.get('socket_url')])
def run(args, expected): output = StringIO() sys.stdout = output ctx_proxy.main(args) self.assertEqual(output.getvalue(), expected)
def test_json_arg_prefix(self): args = ['_1', '@1'] expected_args = [1, '@1'] self.expected.update(dict( args=expected_args)) ctx_proxy.main(args + ['--json-arg-prefix', '_'])
def test_json_args(self): args = ['@1', '@[1,2,3]', '@{"key":"value"}'] expected_args = [1, [1, 2, 3], {'key': 'value'}] self.expected.update(dict( args=expected_args)) ctx_proxy.main(args)
def test_args(self): self.expected.update(dict( args=['1', '2', '3'])) ctx_proxy.main(self.expected.get('args'))
def test_socket_url_env(self): expected_socket_url = 'env_sock_url' os.environ['CTX_SOCKET_URL'] = expected_socket_url self.expected.update(dict( socket_url=expected_socket_url)) ctx_proxy.main([])
def test_socket_url_arg(self): self.expected.update(dict( socket_url='sock_url')) ctx_proxy.main(['--socket-url', self.expected.get('socket_url')])
def test_json_arg_prefix(self): args = ['_1', '@1'] expected_args = [1, '@1'] self.expected.update(dict(args=expected_args)) ctx_proxy.main(args + ['--json-arg-prefix', '_'])
def test_json_args(self): args = ['@1', '@[1,2,3]', '@{"key":"value"}'] expected_args = [1, [1, 2, 3], {'key': 'value'}] self.expected.update(dict(args=expected_args)) ctx_proxy.main(args)
def test_timeout(self): self.expected.update(dict(timeout='10')) ctx_proxy.main(['--timeout', self.expected.get('timeout')]) self.expected.update(dict(timeout='15')) ctx_proxy.main(['-t', self.expected.get('timeout')])
def test_args(self): self.expected.update(dict(args=['1', '2', '3'])) ctx_proxy.main(self.expected.get('args'))
def test_socket_url_env(self): expected_socket_url = 'env_sock_url' os.environ['CTX_SOCKET_URL'] = expected_socket_url self.expected.update(dict(socket_url=expected_socket_url)) ctx_proxy.main([])
def test_socket_url_arg(self): self.expected.update(dict(socket_url='sock_url')) ctx_proxy.main(['--socket-url', self.expected.get('socket_url')])