Exemplo n.º 1
0
 def test_severityCrit(self):
     """
     The syslog severity 'crit' is mapped to 'CRITICAL'.
     """
     eventDict = {'severity': 'crit'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('CRITICAL', eventDict['logLevel'])
Exemplo n.º 2
0
 def test_categoryDefault(self):
     """
     If the category is not set, it is set to C{'syslog'}.
     """
     eventDict = {}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('syslog', eventDict['category'])
Exemplo n.º 3
0
 def test_severityEmerg(self):
     """
     The syslog severity 'emerg' is mapped to 'EMERGENCY'.
     """
     eventDict = {'severity': 'emerg'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('EMERGENCY', eventDict['logLevel'])
Exemplo n.º 4
0
 def test_severityCrit(self):
     """
     The syslog severity 'crit' is mapped to 'CRITICAL'.
     """
     eventDict = {'severity': 'crit'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('CRITICAL', eventDict['logLevel'])
Exemplo n.º 5
0
 def test_categoryAlreadySet(self):
     """
     If the category is set, it is left unchanged.
     """
     eventDict = {'category': 'test'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('test', eventDict['category'])
Exemplo n.º 6
0
 def test_severityEmerg(self):
     """
     The syslog severity 'emerg' is mapped to 'EMERGENCY'.
     """
     eventDict = {'severity': 'emerg'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('EMERGENCY', eventDict['logLevel'])
Exemplo n.º 7
0
 def test_categoryDefault(self):
     """
     If the category is not set, it is set to C{'syslog'}.
     """
     eventDict = {}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('syslog', eventDict['category'])
Exemplo n.º 8
0
 def test_categoryAlreadySet(self):
     """
     If the category is set, it is left unchanged.
     """
     eventDict = {'category': 'test'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('test', eventDict['category'])
Exemplo n.º 9
0
 def test_hostnames(self):
     """
     A matching hostname in the hostname mapping overrides.
     """
     eventDict = {'hostname': 'test'}
     eventDict = syslog.syslogToUDPLogEvent(
         eventDict, hostnames={'test': 'test.example.org'})
     self.assertEqual('test.example.org', eventDict['hostname'])
Exemplo n.º 10
0
 def test_severityWarn(self):
     """
     The syslog severity 'warn' is mapped to 'WARNING'.
     """
     eventDict = {'severity': 'warn'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('WARNING', eventDict['logLevel'])
     self.assertNotIn('severity', eventDict)
Exemplo n.º 11
0
 def test_severityWarn(self):
     """
     The syslog severity 'warn' is mapped to 'WARNING'.
     """
     eventDict = {'severity': 'warn'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('WARNING', eventDict['logLevel'])
     self.assertNotIn('severity', eventDict)
Exemplo n.º 12
0
 def test_severity(self):
     """
     If the syslog event has a severity, it is renamed, mapped to logLevel.
     """
     eventDict = {'severity': 'debug'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('DEBUG', eventDict['logLevel'])
     self.assertNotIn('severity', eventDict)
Exemplo n.º 13
0
 def test_severity(self):
     """
     If the syslog event has a severity, it is renamed, mapped to logLevel.
     """
     eventDict = {'severity': 'debug'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('DEBUG', eventDict['logLevel'])
     self.assertNotIn('severity', eventDict)
Exemplo n.º 14
0
 def test_tag(self):
     """
     If the syslog event has a tag, it is renamed to appname.
     """
     eventDict = {'tag': 'test'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('test', eventDict['appname'])
     self.assertNotIn('tag', eventDict)
Exemplo n.º 15
0
 def test_severityErr(self):
     """
     The syslog severity 'err' is mapped to 'ERROR'.
     """
     eventDict = {'severity': 'err'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('ERROR', eventDict['logLevel'])
     self.assertNotIn('severity', eventDict)
Exemplo n.º 16
0
 def test_tag(self):
     """
     If the syslog event has a tag, it is renamed to appname.
     """
     eventDict = {'tag': 'test'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('test', eventDict['appname'])
     self.assertNotIn('tag', eventDict)
Exemplo n.º 17
0
 def test_severityErr(self):
     """
     The syslog severity 'err' is mapped to 'ERROR'.
     """
     eventDict = {'severity': 'err'}
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual('ERROR', eventDict['logLevel'])
     self.assertNotIn('severity', eventDict)
Exemplo n.º 18
0
 def test_defaultHostnameNoMatch(self):
     """
     A non-matching hostname in the hostname mapping remains unchanged.
     """
     eventDict = {'hostname': 'foo'}
     eventDict = syslog.syslogToUDPLogEvent(
         eventDict, hostnames={'test': 'test.example.org'})
     self.assertEqual('foo', eventDict['hostname'])
Exemplo n.º 19
0
 def test_defaultHostnameNoMatch(self):
     """
     A non-matching hostname in the hostname mapping remains unchanged.
     """
     eventDict = {'hostname': 'foo'}
     eventDict = syslog.syslogToUDPLogEvent(
         eventDict,
         hostnames={'test': 'test.example.org'})
     self.assertEqual('foo', eventDict['hostname'])
Exemplo n.º 20
0
 def test_hostnames(self):
     """
     A matching hostname in the hostname mapping overrides.
     """
     eventDict = {'hostname': 'test'}
     eventDict = syslog.syslogToUDPLogEvent(
         eventDict,
         hostnames={'test': 'test.example.org'})
     self.assertEqual('test.example.org', eventDict['hostname'])
Exemplo n.º 21
0
 def test_timestampSubSecond(self):
     """
     Datetimes with microseconds yield a fractional timestamp.
     """
     eventDict = {
             'timestamp': datetime.datetime(2015, 1, 15, 15, 59, 26, 341000,
                                            tzinfo=tz.tzutc())
             }
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual(1421337566.341, eventDict['timestamp'])
Exemplo n.º 22
0
 def test_timestamp(self):
     """
     The event timestamp is converted to a POSIX timestamp.
     """
     eventDict = {
         'timestamp':
         datetime.datetime(2015, 1, 15, 15, 59, 26, tzinfo=tz.tzutc())
     }
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual(1421337566, eventDict['timestamp'])
Exemplo n.º 23
0
 def test_timestamp(self):
     """
     The event timestamp is converted to a POSIX timestamp.
     """
     eventDict = {
             'timestamp': datetime.datetime(2015, 1, 15, 15, 59, 26,
                                            tzinfo=tz.tzutc())
             }
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual(1421337566, eventDict['timestamp'])
Exemplo n.º 24
0
 def test_timestampSubSecond(self):
     """
     Datetimes with microseconds yield a fractional timestamp.
     """
     eventDict = {
         'timestamp':
         datetime.datetime(2015,
                           1,
                           15,
                           15,
                           59,
                           26,
                           341000,
                           tzinfo=tz.tzutc())
     }
     eventDict = syslog.syslogToUDPLogEvent(eventDict)
     self.assertEqual(1421337566.341, eventDict['timestamp'])