52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
|
import pytest
|
||
|
|
||
|
from util.config.validators import ConfigValidationException
|
||
|
from util.config.validators.validate_actionlog_achiving import ActionLogAchivingValidator
|
||
|
|
||
|
from test.fixtures import *
|
||
|
|
||
|
@pytest.mark.parametrize('unvalidated_config', [
|
||
|
({}),
|
||
|
({'ACTION_LOG_ARCHIVE_PATH': 'foo'}),
|
||
|
({'ACTION_LOG_ARCHIVE_LOCATION': ''}),
|
||
|
])
|
||
|
def test_skip_validate_actionlog(unvalidated_config, app):
|
||
|
validator = ActionLogAchivingValidator()
|
||
|
validator.validate(unvalidated_config, None, None)
|
||
|
|
||
|
|
||
|
@pytest.mark.parametrize('config, expected_error', [
|
||
|
({'FEATURE_ACTION_LOG_ROTATION': True}, 'Missing action log archive path'),
|
||
|
({'FEATURE_ACTION_LOG_ROTATION': True,
|
||
|
'ACTION_LOG_ARCHIVE_PATH': ''}, 'Missing action log archive path'),
|
||
|
({'FEATURE_ACTION_LOG_ROTATION': True,
|
||
|
'ACTION_LOG_ARCHIVE_PATH': 'foo'}, 'Missing action log archive storage location'),
|
||
|
({'FEATURE_ACTION_LOG_ROTATION': True,
|
||
|
'ACTION_LOG_ARCHIVE_PATH': 'foo',
|
||
|
'ACTION_LOG_ARCHIVE_LOCATION': ''}, 'Missing action log archive storage location'),
|
||
|
({'FEATURE_ACTION_LOG_ROTATION': True,
|
||
|
'ACTION_LOG_ARCHIVE_PATH': 'foo',
|
||
|
'ACTION_LOG_ARCHIVE_LOCATION': 'invalid'},
|
||
|
'Action log archive storage location `invalid` not found in storage config'),
|
||
|
])
|
||
|
def test_invalid_config(config, expected_error, app):
|
||
|
validator = ActionLogAchivingValidator()
|
||
|
|
||
|
with pytest.raises(ConfigValidationException) as ipe:
|
||
|
validator.validate(config, None, None)
|
||
|
|
||
|
assert ipe.value.message == expected_error
|
||
|
|
||
|
def test_valid_config(app):
|
||
|
config = {
|
||
|
'FEATURE_ACTION_LOG_ROTATION': True,
|
||
|
'ACTION_LOG_ARCHIVE_PATH': 'somepath',
|
||
|
'ACTION_LOG_ARCHIVE_LOCATION': 'somelocation',
|
||
|
'DISTRIBUTED_STORAGE_CONFIG': {
|
||
|
'somelocation': {},
|
||
|
},
|
||
|
}
|
||
|
|
||
|
validator = ActionLogAchivingValidator()
|
||
|
validator.validate(config, None, None)
|