Beispiel #1
0
 def test_max_line_size(self, mock_log_line_no_size_limit):
     line = create_test_line(MAX_LINE_SIZE_IN_BYTES)
     assert len(line) > MAX_LINE_SIZE_IN_BYTES
     with pytest.raises(LogLineIsTooLongError):
         self.logger.log_line(self.stream, line)
     assert self.logger.report_status.called_with(
         True, 'The log line is dropped (line size larger than %r bytes)' %
         MAX_LINE_SIZE_IN_BYTES)
     assert not mock_log_line_no_size_limit.called
Beispiel #2
0
 def test_warning_line_size(self, mock_log_line_no_size_limit,
                            mock_traceback):
     line = create_test_line(WARNING_LINE_SIZE_IN_BYTES)
     assert len(line) > WARNING_LINE_SIZE_IN_BYTES
     assert len(line) <= MAX_LINE_SIZE_IN_BYTES
     self.logger.log_line(self.stream, line)
     assert self.logger.report_status.called_with(
         False,
         'The log line size is larger than %r bytes (monitored in \'%s\')' %
         (WARNING_LINE_SIZE_IN_BYTES, WHO_CLOG_LARGE_LINE_STREAM))
     assert mock_log_line_no_size_limit.call_count == 2
     call_1 = mock.call(self.stream, line)
     origin_info = {}
     origin_info['stream'] = self.stream
     origin_info['line_size'] = len(line)
     origin_info['traceback'] = ''.join(mock_traceback)
     origin_info_line = json.dumps(origin_info).encode('UTF-8')
     call_2 = mock.call(WHO_CLOG_LARGE_LINE_STREAM, origin_info_line)
     mock_log_line_no_size_limit.assert_has_calls([call_1, call_2])
Beispiel #3
0
 def test_normal_line_size(self, mock_log_line_no_size_limit):
     line = create_test_line()
     assert len(line) <= WARNING_LINE_SIZE_IN_BYTES
     self.logger.log_line(self.stream, line)
     assert not self.logger.report_status.called
     mock_log_line_no_size_limit.assert_called_once_with(self.stream, line)
Beispiel #4
0
 def test_log_line_no_size_limit(self):
     line = create_test_line()
     self.logger._log_line_no_size_limit(self.stream, line)
     wait_on_log_data(self.log_path, line + b'\n')
     assert not self.logger.report_status.called