Ejemplo n.º 1
0
def test_prettify_log_line_valid_json_missing_key():
    line = json.dumps({
        "component": "fake_component",
        "oops_i_spelled_timestamp_rong": "1999-09-09",
    })
    levels = []
    actual = logs.prettify_log_line(line, levels)
    assert "JSON missing keys: %s" % line in actual
Ejemplo n.º 2
0
def test_prettify_log_line_valid_json_missing_key():
    line = json.dumps({
        "component": "fake_component",
        "oops_i_spelled_timestamp_rong": "1999-09-09",
    })
    levels = []
    actual = logs.prettify_log_line(line, levels)
    assert "JSON missing keys: %s" % line in actual
Ejemplo n.º 3
0
def test_prettify_log_line_valid_json_requested_level_is_only_event():
    requested_levels = ['fake_requested_level1']
    parsed_line = {
        "message": "fake_message",
        "component": "fake_component",
        "level": "event",
        "cluster": "fake_cluster",
        "instance": "fake_instance",
        "timestamp": "2015-03-12T21:20:04.602002",
    }
    line = json.dumps(parsed_line)

    actual = logs.prettify_log_line(line, requested_levels)
    assert parsed_line['level'] not in actual
Ejemplo n.º 4
0
def test_prettify_log_line_valid_json_requested_level_is_only_event():
    requested_levels = ['fake_requested_level1']
    parsed_line = {
        "message": "fake_message",
        "component": "fake_component",
        "level": "event",
        "cluster": "fake_cluster",
        "instance": "fake_instance",
        "timestamp": "2015-03-12T21:20:04.602002",
    }
    line = json.dumps(parsed_line)

    actual = logs.prettify_log_line(line, requested_levels)
    assert parsed_line['level'] not in actual
Ejemplo n.º 5
0
def test_prettify_log_line_valid_json():
    parsed_line = {
        "message": "fake_message",
        "component": "fake_component",
        "level": "fake_level",
        "cluster": "fake_cluster",
        "instance": "fake_instance",
        "timestamp": "2015-03-12T21:20:04.602002",
    }
    requested_levels = ['fake_requested_level1', 'fake_requested_level2']
    line = json.dumps(parsed_line)

    actual = logs.prettify_log_line(line, requested_levels)
    expected_timestamp = logs.prettify_timestamp(parsed_line['timestamp'])
    assert expected_timestamp in actual
    assert parsed_line['component'] in actual
    assert parsed_line['cluster'] in actual
    assert parsed_line['instance'] in actual
    assert parsed_line['level'] in actual
    assert parsed_line['message'] in actual
Ejemplo n.º 6
0
def test_prettify_log_line_valid_json():
    parsed_line = {
        "message": "fake_message",
        "component": "fake_component",
        "level": "fake_level",
        "cluster": "fake_cluster",
        "instance": "fake_instance",
        "timestamp": "2015-03-12T21:20:04.602002",
    }
    requested_levels = ['fake_requested_level1', 'fake_requested_level2']
    line = json.dumps(parsed_line)

    actual = logs.prettify_log_line(line, requested_levels)
    expected_timestamp = logs.prettify_timestamp(parsed_line['timestamp'])
    assert expected_timestamp in actual
    assert parsed_line['component'] in actual
    assert parsed_line['cluster'] in actual
    assert parsed_line['instance'] in actual
    assert parsed_line['level'] in actual
    assert parsed_line['message'] in actual
Ejemplo n.º 7
0
def test_prettify_log_line_invalid_json():
    line = "i am not json"
    levels = []
    assert logs.prettify_log_line(line, levels) == "Invalid JSON: %s" % line
Ejemplo n.º 8
0
def test_prettify_log_line_invalid_json():
    line = "i am not json"
    levels = []
    assert logs.prettify_log_line(line, levels) == "Invalid JSON: %s" % line