<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

import pytest

from tests.integration import LOCAL_GRAYLOG_UP
from tests.helper import get_graylog_response, get_unique_message, \
    logger, handler


@pytest.mark.skipif(not LOCAL_GRAYLOG_UP,
                    reason="local graylog instance not up")
def test_non_status_field_log(logger):
    message = get_unique_message()
    logger.error(message, extra={'foo': 'bar'})
    graylog_response = get_graylog_response(message, fields=["foo"])
    assert message == graylog_response['message']
    assert "bar" == graylog_response['_foo']


@pytest.mark.skipif(not LOCAL_GRAYLOG_UP,
                    reason="local graylog instance not up")
def test_status_field_issue(logger):
    message = get_unique_message()
    logger.error(message, extra={'status': 'OK'})
    graylog_response = get_graylog_response(message, fields=["status"])
    assert message == graylog_response['message']
    assert "OK" == graylog_response['status']<commit_msg>adding another test for status field issue<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

import pytest

from tests.integration import LOCAL_GRAYLOG_UP
from tests.helper import get_graylog_response, get_unique_message, \
    logger, handler


@pytest.mark.skipif(not LOCAL_GRAYLOG_UP,
                    reason="local graylog instance not up")
def test_non_status_field_log(logger):
    message = get_unique_message()
    logger.error(message, extra={"foo": "bar"})
    graylog_response = get_graylog_response(message, fields=["foo"])
    assert message == graylog_response["message"]
    assert "bar" == graylog_response["foo"]


@pytest.mark.skipif(not LOCAL_GRAYLOG_UP,
                    reason="local graylog instance not up")
def test_status_field_issue(logger):
    message = get_unique_message()
    logger.error(message, extra={"status": "OK"})
    graylog_response = get_graylog_response(message, fields=["status"])
    assert message == graylog_response["message"]
    assert "OK" == graylog_response["status"]


@pytest.mark.skipif(not LOCAL_GRAYLOG_UP,
                    reason="local graylog instance not up")
def test_status_field_issue_multi(logger):
    message = get_unique_message()
    logger.error(message, extra={"foo": "bar", "status": "OK"})
    graylog_response = get_graylog_response(message, fields=["foo", "status"])
    assert message == graylog_response["message"]
    assert "bar" == graylog_response["foo"]
    assert "OK" == graylog_response["status"]
{'fraction_non_alphanumeric': 0.1251499400239904, 'fraction_numerical': 0.0007996801279488205, 'mean_word_length': 4.56, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6878937', 'n_tokens_mistral': 777, 'n_tokens_neox': 768, 'n_words': 158}