def test_discovery_single(monkeypatch): monkeypatch.setattr(logwatch.logwatch, "get_ec_rule_params", lambda: []) assert sorted(logwatch.discover_logwatch_single([], SECTION1), key=lambda s: s.item or "",) == [ Service(item="empty.log"), Service(item="my_other_log"), Service(item="mylog"), ] assert not list(logwatch.discover_logwatch_groups([], SECTION1))
def test_discovery_single(monkeypatch): monkeypatch.setattr(logwatch, '_get_discovery_groups', lambda: []) monkeypatch.setattr(logwatch.logwatch, 'get_ec_rule_params', lambda: []) assert sorted( logwatch.discover_logwatch_single(SECTION1), key=lambda s: s.item, ) == [ Service(item='empty.log'), Service(item='my_other_log'), Service(item='mylog'), ] assert not list(logwatch.discover_logwatch_groups(SECTION1))
def test_logwatch_discover_groups(monkeypatch): params = [{ "grouping_patterns": [ ('my_%s_group', ('~(log)[^5]', '~.*1')), ('my_%s_group', ('~(log).*', '~.*5')), ], }] monkeypatch.setattr(logwatch.logwatch, 'get_ec_rule_params', lambda: []) assert list(logwatch.discover_logwatch_groups(params, SECTION2)) == [ Service( item='my_log_group', parameters={ 'group_patterns': [ ('~log.*', '~.*5'), ('~log[^5]', '~.*1'), ], }, ), ]
def test_logwatch_discover_groups(monkeypatch): params = [{ "grouping_patterns": [ ("my_%s_group", ("~(log)[^5]", "~.*1")), ("my_%s_group", ("~(log).*", "~.*5")), ], }] monkeypatch.setattr(logwatch.logwatch, "get_ec_rule_params", lambda: []) assert list(logwatch.discover_logwatch_groups(params, SECTION2)) == [ Service( item="my_log_group", parameters={ "group_patterns": [ ("~log.*", "~.*5"), ("~log[^5]", "~.*1"), ], }, ), ]