Beispiel #1
0
    def test_format_record(self):
        """Test format a LogRecord into JSON string."""
        os.environ['FUZZ_TARGET'] = 'fuzz_target1'
        record = self.get_record()
        record.extras = {'a': 1}
        self.assertEqual(
            {
                'message': 'log message',
                'created': '1970-01-01T00:00:10Z',
                'severity': 'INFO',
                'bot_name': 'linux-bot',
                'task_payload': 'fuzz fuzzer1 job1',
                'fuzz_target': 'fuzz_target1',
                'name': 'logger_name',
                'extras': {
                    'a': 1,
                },
                'location': {
                    'path': 'path',
                    'line': 123,
                    'method': 'func'
                }
            }, json.loads(logs.format_record(record)))

        self.mock.update_entry_with_exc.assert_called_once_with(
            mock.ANY, 'exc_info')
Beispiel #2
0
 def test_no_extras(self):
   """Test format record with no extras."""
   record = self.get_record()
   record.extras = None
   self.assertEqual({
       'message': 'log message',
       'created': '1970-01-01T00:00:10Z',
       'severity': 'INFO',
       'bot_name': 'linux-bot',
       'task_payload': 'fuzz fuzzer1 job1',
       'name': 'logger_name',
       'location': {
           'path': 'path',
           'line': 123,
           'method': 'func'
       }
   }, json.loads(logs.format_record(record)))
   self.mock.update_entry_with_exc.assert_called_once_with(
       mock.ANY, 'exc_info')