예제 #1
0
 def test_commands_with_args_can_be_called(self):
     task_list = tr.generate_task_list()
     result_map = tr.exec_task("echo:zulu", task_list)
     expected = {
         'rc': 0,
         'result': 'received: zulu',
         'task': 'echo',
         'task_args': ['zulu'],
         'task_kwargs': {}
     }
     self.assertEqual(expected, result_map)
예제 #2
0
 def test_commands_can_be_called(self):
     task_list = tr.generate_task_list()
     result_map = tr.exec_task("ping", task_list)
     expected = {
         'task': 'ping',
         'task_args': [],
         'task_kwargs': {},
         'result': 'pong',
         'rc': SUCCESS_RC
     }
     self.assertEqual(expected, result_map)
예제 #3
0
 def test_quoted_commands_can_be_called(self):
     task_list = tr.generate_task_list()
     # result_map = tr.exec_task("echo:'hello\, world'", task_list) # this is what we give bash
     result_map = tr.exec_task(r"echo:hello\, world",
                               task_list)  # this is what we see after bash
     expected = {
         'rc': 0,
         'result': 'received: hello, world',
         'task': 'echo',
         'task_args': ['hello, world'],
         'task_kwargs': {}
     }
     self.assertEqual(expected, result_map)
예제 #4
0
 def test_commands_with_whitespace_can_be_called(self):
     task_list = tr.generate_task_list()
     # result_map = tr.exec_task("echo:msg,'echo hello world'", task_list) # this is what we give bash
     result_map = tr.exec_task("echo:msg,echo hello world",
                               task_list)  # this is what we see after bash
     expected = {
         'task': 'echo',
         'task_args': ['msg', 'echo hello world'],
         'task_kwargs': {},
         'result':
         "received: msg with args: ('echo hello world',) and kwargs: {}",
         'rc': SUCCESS_RC
     }
     self.assertEqual(expected, result_map)
예제 #5
0
 def test_commands_with_args_and_kwargs_can_be_called(self):
     task_list = tr.generate_task_list()
     result_map = tr.exec_task("echo:msg,arg,key=val", task_list)
     expected = {
         'rc': 0,
         'result':
         "received: msg with args: ('arg',) and kwargs: {'key': 'val'}",
         'task': 'echo',
         'task_args': ['msg', 'arg'],
         'task_kwargs': {
             'key': 'val'
         }
     }
     self.assertEqual(expected, result_map)
예제 #6
0
    def test_commands_with_special_chars_can_be_called_without_quoting(self):
        task_list = tr.generate_task_list()
        # result_map = tr.exec_task("echo:'hello-world!@$%^&*()-;?/'", task_list) # this is what we give bash
        result_map = tr.exec_task("echo:hello-world!@$%^&*()-;?/",
                                  task_list)  # this is what we see after bash

        # result_map = tr.exec_task('echo:"hello-world\!@$%^&*()-;?/"', task_list) # double quotes must escape certain shell characters
        # result_map = tr.exec_task('echo:hello-world\\!@$%^&*()-;?/', task_list) # this is what we see after bash with double quotes

        expected = {
            'rc': 0,
            'result': 'received: hello-world!@$%^&*()-;?/',
            'task': 'echo',
            'task_args': ['hello-world!@$%^&*()-;?/'],
            'task_kwargs': {}
        }
        self.assertEqual(expected, result_map)