Beispiel #1
0
def test_logwatch_discover_single_groups(monkeypatch):
    params = [{"grouping_patterns": [('my_group', ('~log.*', '~.*1')),]}]

    monkeypatch.setattr(logwatch.logwatch, 'get_ec_rule_params', lambda: [])

    assert list(logwatch.discover_logwatch_single(params, SECTION2)) == [
        Service(item='log1'),
    ]
Beispiel #2
0
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))
Beispiel #3
0
def test_logwatch_discover_single_restrict(monkeypatch):
    monkeypatch.setattr(
        logwatch.logwatch,
        "get_ec_rule_params",
        lambda: [{"restrict_logfiles": [".*2"]}],
    )
    assert sorted(logwatch.discover_logwatch_single([], SECTION2), key=lambda s: s.item or "",) == [
        Service(item="log1"),
        Service(item="log5"),
    ]
Beispiel #4
0
def test_logwatch_discover_single_groups(monkeypatch):
    monkeypatch.setattr(
        logwatch,
        '_get_discovery_groups',
        lambda: [[('my_group', ('~log.*', '~.*1'))]],
    )
    monkeypatch.setattr(logwatch.logwatch, 'get_ec_rule_params', lambda: [])

    assert list(logwatch.discover_logwatch_single(SECTION2)) == [
        Service(item='log1'),
    ]
Beispiel #5
0
def test_logwatch_discover_single_groups(monkeypatch):
    params = [{
        "grouping_patterns": [
            ("my_group", ("~log.*", "~.*1")),
        ]
    }]

    monkeypatch.setattr(logwatch.logwatch, "get_ec_rule_params", lambda: [])

    assert list(logwatch.discover_logwatch_single(params, SECTION2)) == [
        Service(item="log1"),
    ]
Beispiel #6
0
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))
Beispiel #7
0
def test_logwatch_discover_single_restrict(monkeypatch):
    monkeypatch.setattr(logwatch, '_get_discovery_groups', lambda: [])
    monkeypatch.setattr(
        logwatch.logwatch,
        'get_ec_rule_params',
        lambda: [Parameters({'restrict_logfiles': [u'.*2']})],
    )
    assert sorted(
        logwatch.discover_logwatch_single(SECTION2),
        key=lambda s: s.item,
    ) == [
        Service(item='log1'),
        Service(item='log5'),
    ]
Beispiel #8
0
def test_logwatch_discover_single_restrict(monkeypatch):
    monkeypatch.setattr(
        logwatch.logwatch,
        'get_ec_rule_params',
        lambda: [{
            'restrict_logfiles': [u'.*2']
        }],
    )
    assert sorted(
        logwatch.discover_logwatch_single([], SECTION2),
        key=lambda s: s.item or "",
    ) == [
        Service(item='log1'),
        Service(item='log5'),
    ]