def test_format_with_timestamp(self): log = TailFormatter('({timestamp}) - {message}', color=False).format(self.message) timestamp_local_format = self.timestamp.to('local').format( utils.DEFAULT_DATE_FORMAT) self.assertEquals( '({}) - dummy message'.format(timestamp_local_format), log)
def test_format_with_blank_fields(self): log = TailFormatter('{blank_field}', fields=['blank_field'], color=False).format(self.message) self.assertEquals('', log)
def test_format_with_custom_fields(self): log = TailFormatter('{a} {b} {c}', fields=['a', 'b', 'c'], color=False).format(self.message) self.assertEquals('1 2 3', log)
def test_format_with_log_level(self): log = TailFormatter('({level}) - {message}', color=False).format(self.message) self.assertEquals('(DEBUG) - dummy message', log)
def test_format_colored_with_level_critical(self): self.message.level = syslog.LOG_CRIT log = TailFormatter('({source}) - {message}', color=True).format(self.message) self.assertEquals( colored('(dummy.source) - dummy message', 'white', 'on_red'), log)
def test_format_colored_with_level_warning(self): self.message.level = syslog.LOG_WARNING log = TailFormatter('({source}) - {message}', color=True).format(self.message) self.assertEquals(colored('(dummy.source) - dummy message', 'yellow'), log)
def test_format_colored_with_level_info(self): self.message.level = syslog.LOG_INFO log = TailFormatter('({source}) - {message}', color=True).format(self.message) self.assertEquals(colored('(dummy.source) - dummy message', 'green'), log)
def test_format_colored_with_level_debug(self): self.message.level = syslog.LOG_DEBUG log = TailFormatter('({source}) - {message}', color=True).format(self.message) self.assertEquals(colored('(dummy.source) - dummy message', 'cyan'), log)
def test_format(self): log = TailFormatter('({source}) - {message}', color=False).format(self.message) self.assertEquals('(dummy.source) - dummy message', log)