Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/tests/test_server.py
Show First 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | def test_check_config_not_local() -> None: | ||||
) | ) | ||||
with pytest.raises(EnvironmentError, match=expected_error): | with pytest.raises(EnvironmentError, match=expected_error): | ||||
check_config({"vault": {"cls": "remote"}}) | check_config({"vault": {"cls": "remote"}}) | ||||
@pytest.mark.parametrize("missing_key", ["storage", "cache", "scheduler"]) | @pytest.mark.parametrize("missing_key", ["storage", "cache", "scheduler"]) | ||||
def test_check_config_missing_key(missing_key, swh_vault_config) -> None: | def test_check_config_missing_key(missing_key, swh_vault_config) -> None: | ||||
"""Any other configuration than 'local' (the default) is rejected""" | """Any other configuration than 'local' (the default) is rejected""" | ||||
config_ok = {"vault": {"cls": "local", "args": swh_vault_config}} | config_ok = {"vault": {"cls": "local", **swh_vault_config}} | ||||
config_ko = copy.deepcopy(config_ok) | config_ko = copy.deepcopy(config_ok) | ||||
config_ko["vault"]["args"].pop(missing_key, None) | config_ko["vault"].pop(missing_key, None) | ||||
expected_error = f"invalid configuration: missing {missing_key} config entry" | expected_error = f"invalid configuration: missing {missing_key} config entry" | ||||
with pytest.raises(ValueError, match=expected_error): | with pytest.raises(ValueError, match=expected_error): | ||||
check_config(config_ko) | check_config(config_ko) | ||||
@pytest.mark.parametrize("missing_key", ["storage", "cache", "scheduler"]) | @pytest.mark.parametrize("missing_key", ["storage", "cache", "scheduler"]) | ||||
def test_check_config_ok(missing_key, swh_vault_config) -> None: | def test_check_config_ok(missing_key, swh_vault_config) -> None: | ||||
"""Any other configuration than 'local' (the default) is rejected""" | """Any other configuration than 'local' (the default) is rejected""" | ||||
config_ok = {"vault": {"cls": "local", "args": swh_vault_config}} | config_ok = {"vault": {"cls": "local", **swh_vault_config}} | ||||
assert check_config(config_ok) is not None | assert check_config(config_ok) is not None |