""" Pipe task runner. This task runner is responsible for running all tasks that take in stdin as input and stdout as output. The data will be piped through the work flow. """ import tempfile from unittest.mock import MagicMock from garcon_contrib.pipe import garcon_pipe_task_runner def test_pipe_taskrunner(): tmp = tempfile.TemporaryFile(mode='w+t') tmp.close() resp = dict(foo='bar', bazz=tmp) runner = garcon_pipe_task_runner.Pipe( MagicMock(), MagicMock(return_value=resp)) result = runner.execute(None, dict()) assert len(runner.tasks) == 2 for current_task in runner.tasks: assert current_task.called del resp['bazz'] # io.TextIOWrapper objects don't go to the context assert result == resp