missing_key = 'cache'
swh_vault_config = {'cache': {'args': {'allow_delete': True, 'root': '/tmp/pytest-of-jenkins/pytest-0/test_check_config_missing_key_1', '...oot': '/tmp/pytest-of-jenkins/pytest-0/test_check_config_missing_key_1', 'slicing': '0:1/1:5'}, 'cls': 'pathslicing'}}}
@pytest.mark.parametrize("missing_key", ["storage", "cache", "scheduler"])
def test_check_config_missing_key(missing_key, swh_vault_config) -> None:
"""Any other configuration than 'local' (the default) is rejected"""
config_ok = {"vault": {"cls": "local", **swh_vault_config}}
config_ko = copy.deepcopy(config_ok)
config_ko["vault"].pop(missing_key, None)
expected_error = f"invalid configuration: missing {missing_key} config entry"
with pytest.raises(ValueError, match=expected_error):
> check_config(config_ko)
.tox/py3/lib/python3.7/site-packages/swh/vault/tests/test_server.py:154:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cfg = {'vault': {'cls': 'local', 'db': "dbname=vault user=postgres host=127.0.0.1 port=13272 options=''", 'scheduler': {'cls...ot': '/tmp/pytest-of-jenkins/pytest-0/test_check_config_missing_key_1', 'slicing': '0:1/1:5'}, 'cls': 'pathslicing'}}}}
def check_config(cfg: Dict[str, Any]) -> Dict[str, Any]:
"""Ensure the configuration is ok to run a local vault server
Raises:
EnvironmentError if the configuration is not for local instance
ValueError if one of the following keys is missing: vault, cache, storage,
scheduler
Returns:
Configuration dict to instantiate a local vault server instance
"""
if "vault" not in cfg:
raise ValueError("missing 'vault' configuration")
vcfg = cfg["vault"]
if vcfg["cls"] != "local":
raise EnvironmentError(
"The vault backend can only be started with a 'local' configuration",
)
> args = {**vcfg, **vcfg.get("args")}
E TypeError: 'NoneType' object is not a mapping
.tox/py3/lib/python3.7/site-packages/swh/vault/api/server.py:71: TypeError
TEST RESULT
TEST RESULT
- Run At
- Oct 23 2020, 6:57 PM