Add S3 storage test to validator tests
This commit is contained in:
parent
09b3cfd549
commit
e76b95f0e6
2 changed files with 20 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import moto
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from util.config.validators import ConfigValidationException
|
from util.config.validators import ConfigValidationException
|
||||||
|
@ -16,3 +17,20 @@ def test_validate_storage(unvalidated_config, expected):
|
||||||
validator.validate(unvalidated_config, None, None)
|
validator.validate(unvalidated_config, None, None)
|
||||||
else:
|
else:
|
||||||
validator.validate(unvalidated_config, None, None)
|
validator.validate(unvalidated_config, None, None)
|
||||||
|
|
||||||
|
def test_validate_s3_storage():
|
||||||
|
validator = StorageValidator()
|
||||||
|
with moto.mock_s3():
|
||||||
|
with pytest.raises(ConfigValidationException) as ipe:
|
||||||
|
validator.validate({
|
||||||
|
'DISTRIBUTED_STORAGE_CONFIG': {
|
||||||
|
'default': ('S3Storage', {
|
||||||
|
's3_access_key': 'invalid',
|
||||||
|
's3_secret_key': 'invalid',
|
||||||
|
's3_bucket': 'somebucket',
|
||||||
|
'storage_path': ''
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}, None, None)
|
||||||
|
|
||||||
|
assert ipe.value.message == 'Invalid storage configuration: default: S3ResponseError: 404 Not Found'
|
|
@ -26,7 +26,8 @@ class StorageValidator(BaseValidator):
|
||||||
# Run setup on the driver if the read/write succeeded.
|
# Run setup on the driver if the read/write succeeded.
|
||||||
driver.setup()
|
driver.setup()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise ConfigValidationException('Invalid storage configuration: %s: %s' % (name, str(ex)))
|
msg = str(ex).strip()
|
||||||
|
raise ConfigValidationException('Invalid storage configuration: %s: %s' % (name, msg))
|
||||||
|
|
||||||
|
|
||||||
def _get_storage_providers(config):
|
def _get_storage_providers(config):
|
||||||
|
|
Reference in a new issue