Add S3 storage test to validator tests

This commit is contained in:
Joseph Schorr 2017-02-15 13:11:16 -05:00
parent 09b3cfd549
commit e76b95f0e6
2 changed files with 20 additions and 1 deletions

View file

@ -1,3 +1,4 @@
import moto
import pytest
from util.config.validators import ConfigValidationException
@ -16,3 +17,20 @@ def test_validate_storage(unvalidated_config, expected):
validator.validate(unvalidated_config, None, None)
else:
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'

View file

@ -26,7 +26,8 @@ class StorageValidator(BaseValidator):
# Run setup on the driver if the read/write succeeded.
driver.setup()
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):