示例#1
0
def test_exclude_mode():
    '''Test only logs with matching value fail when mode is EXCLUDE.'''
    log = Log(name='sawmill.test.one')
    filterer = Pattern('sawmill\.test\..*', mode=Pattern.EXCLUDE)
    assert filterer.filter([log]) == []

    log = Log(name='sawmill.other.one')
    assert filterer.filter([log]) == [log]
示例#2
0
def test_different_key():
    '''Test using key other than name.'''
    log = Log()
    filterer = Pattern('A message', key='message')
    assert filterer.filter([log]) == [log]

    log = Log(message='A message')
    filterer = Pattern('A message', key='message')
    assert filterer.filter([log]) == [log]

    log = Log(message='Another message')
    filterer = Pattern('A message', key='message')
    assert filterer.filter([log]) == []

    log = Log(message='A message')
    filterer = Pattern('A message', key='message', mode=Pattern.EXCLUDE)
    assert filterer.filter([log]) == []
示例#3
0
def test_non_string_key_fails():
    '''Test log record with non-string key fails.'''
    log = Log(name=None)
    filterer = Pattern('sawmill\.test\..*')
    assert filterer.filter([log]) == []
示例#4
0
def test_missing_key_passes():
    '''Test log record with missing key passes.'''
    log = Log()
    filterer = Pattern('sawmill\.test\..*')
    assert filterer.filter([log]) == [log]