示例#1
0
    def test_log_document_positive(self):
        logger = LstailLogger(LOG_DOCUMENT_CONFIG,
                              output=sys.stdout,
                              verbose=False)
        logger.update_display_columns()

        # positive test
        logger.log_document(LOG_DOCUMENT_TEST_DOCUMENT)
        # check
        expected_output = '{}    localhost    message content'.format(
            LOG_DOCUMENT_TIMESTAMP)
        output = sys.stdout.getvalue().strip()  # pylint: disable=no-member
        self.assertEqual(output, expected_output)
示例#2
0
    def test_update_display_columns(self):
        default_column_names = ['column1', 'column2']
        config = mock.Mock(kibana=mock.Mock(
            default_columns=default_column_names))
        logger = LstailLogger(config, output=sys.stdout, verbose=False)

        # columns = None
        logger.update_display_columns(columns=None)
        expected_columns = ['document_id', 'timestamp'] + default_column_names
        self.assertEqual(logger._display_columns, expected_columns)

        # columns = custom
        test_columns = ['test_col1', 'test_col2', 'test_col3']
        logger.update_display_columns(columns=test_columns)
        expected_columns = ['document_id', 'timestamp'] + test_columns
        self.assertEqual(logger._display_columns, expected_columns)