コード例 #1
0
ファイル: test.py プロジェクト: alex2/vorlauf
 def test_pipeline_add_order(self):
     process1 = Process('first')
     process2 = Process('second')
     pipeline = Pipeline()
     pipeline.add(process1)
     pipeline.add(process2)
     self.assertEqual(pipeline.pipeline, [process1, process2])
コード例 #2
0
ファイル: test.py プロジェクト: alex2/vorlauf
 def test_pipeline_single_process(self):
     process = Process('md5sum')
     pipeline = Pipeline([process])
     stdin = self.fd_from_string('fubar')
     popen_p, = pipeline.run(stdin=stdin, stdout=self.stdout)
     self.assertEqual(popen_p.returncode, 0)
     self.assertEqual(self.get_stdout(), '5185e8b8fd8a71fc80545e144f91faf2  -\n')
コード例 #3
0
ファイル: test.py プロジェクト: alex2/vorlauf
 def test_run_single(self):
     mock_process = mock.Mock()
     pipeline = Pipeline([mock_process])
     processes = pipeline.run('in', 'out')
     self.assertEqual(len(processes), 1)
     mock_process.run.assert_called_once_with(stdin='in', stdout='out')
     # communicate and wait called on only process
     processes[0].communicate.assert_called_once_with()
     processes[0].wait.assert_called_once_with()
コード例 #4
0
ファイル: test.py プロジェクト: alex2/vorlauf
    def test_pipeline_single_process_large_stream(self):
        with open(words_file) as fd:
            pipeline = Pipeline()
            pipeline.add(Process('cat', words_file))
            pipeline.run(stdin=fd, stdout=self.stdout)

        self.assertEqual(
            self.file_length(words_file),
            self.file_length(self.stdout_path)
        )
コード例 #5
0
ファイル: test.py プロジェクト: alex2/vorlauf
 def test_create_processes_two(self):
     mock_process_1 = mock.Mock()
     mock_process_2 = mock.Mock()
     pipeline = Pipeline([mock_process_1, mock_process_2])
     processes = pipeline.create_processes('in', 'out')
     self.assertEqual(len(processes), 2)
     mock_process_1.run.assert_called_once_with(stdin='in', stdout=PIPE)
     mock_process_2.run.assert_called_once_with(
         stdin=mock_process_1.run().stdout, stdout='out'
     )
コード例 #6
0
ファイル: test.py プロジェクト: alex2/vorlauf
 def test_run_two(self):
     mock_process_1 = mock.Mock()
     mock_process_2 = mock.Mock()
     pipeline = Pipeline([mock_process_1, mock_process_2])
     processes = pipeline.run('in', 'out')
     self.assertEqual(len(processes), 2)
     # wait called on first
     processes[0].wait.assert_called_once_with()
     processes[0].communicate.assert_not_called()
     # communicate called on last
     processes[1].wait.assert_not_called()
     processes[1].communicate.assert_called_once_with()
コード例 #7
0
ファイル: test.py プロジェクト: alex2/vorlauf
 def test_pipeline_add(self):
     process = Process('cat', 'foo')
     pipeline = Pipeline()
     pipeline.add(process)
     self.assertEqual(pipeline.pipeline, [process])
コード例 #8
0
ファイル: test.py プロジェクト: alex2/vorlauf
 def test_create_processes_single(self):
     mock_process = mock.Mock()
     pipeline = Pipeline([mock_process])
     processes = pipeline.create_processes('in', 'out')
     self.assertEqual(len(processes), 1)
     mock_process.run.assert_called_once_with(stdin='in', stdout='out')