class_storage = 'remote'
tmpdir = local('/tmp/pytest-of-jenkins/pytest-0/test_load_and_check_config_rem0')
@pytest.mark.parametrize("class_storage", ["remote", "memory"])
def test_load_and_check_config_remote_config_local_type_raise(
class_storage, tmpdir
) -> None:
"""Any other configuration than 'local' (the default) is rejected"""
assert class_storage != "local"
incompatible_config = {"indexer_storage": {"cls": class_storage}}
config_path = prepare_config_file(tmpdir, incompatible_config)
expected_error = (
"The indexer_storage backend can only be started with a 'local' "
"configuration"
)
with pytest.raises(ValueError, match=expected_error):
> load_and_check_config(config_path)
.tox/py3/lib/python3.7/site-packages/swh/indexer/tests/storage/test_server.py:70:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
config_path = '/tmp/pytest-of-jenkins/pytest-0/test_load_and_check_config_rem0/config.yml'
type = 'local'
def load_and_check_config(
config_path: Optional[str], type: str = "local"
) -> Dict[str, Any]:
"""Check the minimal configuration is set to run the api or raise an
error explanation.
Args:
config_path: Path to the configuration file to load
type: configuration type. For 'local' type, more
checks are done.
Raises:
Error if the setup is not as expected
Returns:
configuration as a dict
"""
if not config_path:
raise EnvironmentError("Configuration file must be defined")
if not os.path.exists(config_path):
raise FileNotFoundError(f"Configuration file {config_path} does not exist")
cfg = config.read(config_path)
if "indexer_storage" not in cfg:
raise KeyError("Missing '%indexer_storage' configuration")
if type == "local":
vcfg = cfg["indexer_storage"]
cls = vcfg.get("cls")
if cls not in ("local", "postgresql"):
raise ValueError(
> "The indexer_storage backend can only be started with a "
"'postgresql' configuration"
)
E ValueError: The indexer_storage backend can only be started with a 'postgresql' configuration
.tox/py3/lib/python3.7/site-packages/swh/indexer/storage/api/server.py:91: ValueError
During handling of the above exception, another exception occurred:
class_storage = 'remote'
tmpdir = local('/tmp/pytest-of-jenkins/pytest-0/test_load_and_check_config_rem0')
@pytest.mark.parametrize("class_storage", ["remote", "memory"])
def test_load_and_check_config_remote_config_local_type_raise(
class_storage, tmpdir
) -> None:
"""Any other configuration than 'local' (the default) is rejected"""
assert class_storage != "local"
incompatible_config = {"indexer_storage": {"cls": class_storage}}
config_path = prepare_config_file(tmpdir, incompatible_config)
expected_error = (
"The indexer_storage backend can only be started with a 'local' "
"configuration"
)
with pytest.raises(ValueError, match=expected_error):
> load_and_check_config(config_path)
E AssertionError: Regex pattern "The indexer_storage backend can only be started with a 'local' configuration" does not match "The indexer_storage backend can only be started with a 'postgresql' configuration".
.tox/py3/lib/python3.7/site-packages/swh/indexer/tests/storage/test_server.py:70: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Jun 2 2022, 3:17 PM