예제 #1
0
 def test_command_with_one_pipeline(self):
     self.assertEqual(shlex_split_and_group_by_commands("cat | python"), [
         {
             cmd: ['cat'],
             out: subprocess.PIPE,
             err: None
         },
         {
             cmd: ['python'],
             out: None,
             err: None
         },
     ])
     self.assertEqual(shlex_split_and_group_by_commands("cat &| python"), [
         {
             cmd: ['cat'],
             out: subprocess.PIPE,
             err: subprocess.STDOUT
         },
         {
             cmd: ['python'],
             out: None,
             err: None
         },
     ])
예제 #2
0
파일: test_execute3.py 프로젝트: 8iq/wflow
 def test_one_command(self):
     self.assertEqual(
         shlex_split_and_group_by_commands("cat"),
         [
             {cmd: ['cat'], out: None, err: None}, ])
     self.assertEqual(
         shlex_split_and_group_by_commands("cat qwer aaa"),
         [
             {cmd: ['cat', 'qwer', 'aaa'], out: None, err: None}, ])
예제 #3
0
파일: test_execute3.py 프로젝트: 8iq/wflow
 def test_command_with_one_pipeline(self):
     self.assertEqual(
         shlex_split_and_group_by_commands("cat | python"),
         [
             {cmd: ['cat'], out: subprocess.PIPE, err: None},
             {cmd: ['python'], out: None, err: None}, ])
     self.assertEqual(
         shlex_split_and_group_by_commands("cat &| python"),
         [
             {cmd: ['cat'], out: subprocess.PIPE, err: subprocess.STDOUT},
             {cmd: ['python'], out: None, err: None}, ])
예제 #4
0
 def test_one_command(self):
     self.assertEqual(shlex_split_and_group_by_commands("cat"), [
         {
             cmd: ['cat'],
             out: None,
             err: None
         },
     ])
     self.assertEqual(shlex_split_and_group_by_commands("cat qwer aaa"), [
         {
             cmd: ['cat', 'qwer', 'aaa'],
             out: None,
             err: None
         },
     ])
예제 #5
0
파일: test_execute3.py 프로젝트: 8iq/wflow
 def test_two_pipelines(self):
     self.assertEqual(
         shlex_split_and_group_by_commands("cat | py |& hall"),
         [
             {cmd: ['cat'], out: subprocess.PIPE, err: None},
             {cmd: ['py'], out: subprocess.PIPE, err: subprocess.STDOUT},
             {cmd: ['hall'], out: None, err: None}])
예제 #6
0
파일: test_execute3.py 프로젝트: 8iq/wflow
 def test_redirect_stderr_and_pipline_stdout(self):
     self.assertEqual(
         shlex_split_and_group_by_commands("cat 2> err.log | py"),
         [
             {cmd: ['cat'], err: {file: 'err.log', mode: 'wb'},
              out: subprocess.PIPE},
             {cmd: ['py'], err: None, out: None}, ])
예제 #7
0
파일: test_execute3.py 프로젝트: 8iq/wflow
    def test_command_without_pipeline_and_redirection(self):
        COMMAND = "echo test"
        SPITED_RESULT = [
            {cmd: ['echo', 'test'], out: None, err: None},
        ]

        result = shlex_split_and_group_by_commands(COMMAND)
        self.assertEqual(result, SPITED_RESULT)
예제 #8
0
 def test_stdout_redirection(self):
     self.assertEqual(shlex_split_and_group_by_commands("cat > aaa"), [
         {
             cmd: ['cat'],
             out: {
                 file: 'aaa',
                 mode: 'wb'
             },
             err: None
         },
     ])
예제 #9
0
    def test_command_without_pipeline_and_redirection(self):
        COMMAND = "echo test"
        SPITED_RESULT = [
            {
                cmd: ['echo', 'test'],
                out: None,
                err: None
            },
        ]

        result = shlex_split_and_group_by_commands(COMMAND)
        self.assertEqual(result, SPITED_RESULT)
예제 #10
0
 def test_two_pipelines(self):
     self.assertEqual(shlex_split_and_group_by_commands("cat | py |& hall"),
                      [{
                          cmd: ['cat'],
                          out: subprocess.PIPE,
                          err: None
                      }, {
                          cmd: ['py'],
                          out: subprocess.PIPE,
                          err: subprocess.STDOUT
                      }, {
                          cmd: ['hall'],
                          out: None,
                          err: None
                      }])
예제 #11
0
 def test_redirect_stderr_and_pipline_stdout(self):
     self.assertEqual(
         shlex_split_and_group_by_commands("cat 2> err.log | py"), [
             {
                 cmd: ['cat'],
                 err: {
                     file: 'err.log',
                     mode: 'wb'
                 },
                 out: subprocess.PIPE
             },
             {
                 cmd: ['py'],
                 err: None,
                 out: None
             },
         ])
예제 #12
0
파일: test_execute3.py 프로젝트: 8iq/wflow
    def test_command_with_or_condition_without_pipeline_and_redirection(self):
        COMMAND = "exit || echo problem"

        with self.assertRaises(ExecuteCommandParseError):
            shlex_split_and_group_by_commands(COMMAND)
예제 #13
0
파일: test_execute3.py 프로젝트: 8iq/wflow
 def test_stdout_and_stderr_redirection(self):
     self.assertEqual(
         shlex_split_and_group_by_commands("cat > aaa 2> bbb"),
         [
             {cmd: ['cat'], out: {file: 'aaa', mode: 'wb'},
              err: {file: 'bbb', mode: 'wb'}}, ])
예제 #14
0
    def test_command_with_or_condition_without_pipeline_and_redirection(self):
        COMMAND = "exit || echo problem"

        with self.assertRaises(ExecuteCommandParseError):
            shlex_split_and_group_by_commands(COMMAND)
예제 #15
0
    def test_command_with_and_condition_without_pipeline_and_redirection(self):
        COMMAND = "cd test && ls"

        with self.assertRaises(ExecuteCommandParseError):
            shlex_split_and_group_by_commands(COMMAND)
예제 #16
0
    def test_exception_if_redirect_stdout_and_pipline_with_stderr(self):
        with self.assertRaises(ExecuteCommandParseError) as cm:
            shlex_split_and_group_by_commands("cat > aaa |& qwe")

        self.assertIn("Override redirection by pipeline", str(cm.exception))
예제 #17
0
파일: test_execute3.py 프로젝트: 8iq/wflow
    def test_command_with_and_condition_without_pipeline_and_redirection(self):
        COMMAND = "cd test && ls"

        with self.assertRaises(ExecuteCommandParseError):
            shlex_split_and_group_by_commands(COMMAND)
예제 #18
0
파일: test_execute3.py 프로젝트: 8iq/wflow
    def test_exception_if_redirect_stdout_and_pipline_with_stderr(self):
        with self.assertRaises(ExecuteCommandParseError) as cm:
            shlex_split_and_group_by_commands("cat > aaa |& qwe")

        self.assertIn("Override redirection by pipeline", str(cm.exception))