Пример #1
0
def test_process_actions_invalid(mocker):
    # no type
    with pytest.raises(config.ConfigError):
        config._process_actions({'foo': {'auto': False}})
    # invalid type
    with pytest.raises(config.ConfigError):
        mocker.patch('logstapo.actions.Action.from_config', side_effect=config.ConfigError)
        config._process_actions({'foo': {'type': 'invalid'}})
Пример #2
0
def test_process_actions_invalid(mocker):
    # no type
    with pytest.raises(config.ConfigError):
        config._process_actions({'foo': {'auto': False}})
    # invalid type
    with pytest.raises(config.ConfigError):
        mocker.patch('logstapo.actions.Action.from_config',
                     side_effect=config.ConfigError)
        config._process_actions({'foo': {'type': 'invalid'}})
Пример #3
0
def test_process_actions(mocker):
    class DummyAction(Action):
        def __init__(self, data, type_):
            self.type = type_
            self.data = data

        def __eq__(self, other):
            return self.type == other.type and self.data == other.data

    mocker.patch('logstapo.actions.Action.from_config',
                 lambda type_, data: DummyAction(data, type_))
    actions, auto_actions = config._process_actions({
        'foo': {
            'type': 'FOO',
            'hello': 'world'
        },
        'bar': {
            'type': 'BAR',
            'auto': False
        }
    })
    assert actions == {
        'foo': DummyAction({'hello': 'world'}, 'FOO'),
        'bar': DummyAction({}, 'BAR')
    }
    assert auto_actions == {'foo'}
Пример #4
0
def test_process_actions(mocker):
    class DummyAction(Action):
        def __init__(self, data, type_):
            self.type = type_
            self.data = data

        def __eq__(self, other):
            return self.type == other.type and self.data == other.data

    mocker.patch('logstapo.actions.Action.from_config', lambda type_, data: DummyAction(data, type_))
    actions, auto_actions = config._process_actions({'foo': {'type': 'FOO', 'hello': 'world'},
                                                     'bar': {'type': 'BAR', 'auto': False}})
    assert actions == {'foo': DummyAction({'hello': 'world'}, 'FOO'),
                       'bar': DummyAction({}, 'BAR')}
    assert auto_actions == {'foo'}