Example #1
0
    def test_get_read_process_output_with_exception(self):
        """
        rapid-unit: Rapid Client:Logging:Can read the output from external process
        :return:
        :rtype:
        """
        mock_logger = Mock()
        mock_child_process = Mock()

        def readline(*args, **kwargs):
            raise Exception("Shouldn't see this.")

        mock_child_process.stdout.readline = readline

        executor = Executor(WorkRequest(), "bogus", mock_logger)

        executor._read_process_output(mock_logger, mock_child_process)
        mock_logger.info.assert_called_with("__RCI_{}__ - {} - {}".format(None, os.getpid(), "Shouldn't see this."))
Example #2
0
    def test_get_read_process_output(self):
        """
        rapid-unit: Rapid Client:Logging:Can read the output from external process
        :return:
        :rtype:
        """
        mock_logger = Mock()
        mock_child_process = Mock()

        results = ["testing", b'']

        def readline(*args, **kwargs):
            return results.pop(0)

        mock_child_process.stdout.readline = readline

        executor = Executor(WorkRequest(), "bogus", mock_logger)

        executor._read_process_output(mock_logger, mock_child_process)
        mock_logger.info.assert_called_with("__RCI_{}__ - {} - {}".format(None, os.getpid(), "Cleaning up thread."))