Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/tests/test_server.py
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | with pytest.raises(KeyError, match="missing cls config entry"): | ||||
load_and_check_config(config_path) | load_and_check_config(config_path) | ||||
def test_load_and_check_config_invalid_configuration_level2(tmpdir): | def test_load_and_check_config_invalid_configuration_level2(tmpdir): | ||||
"""Invalid configuration at 2nd level raises""" | """Invalid configuration at 2nd level raises""" | ||||
config = { | config = { | ||||
"objstorage": { | "objstorage": { | ||||
"cls": "pathslicing", | "cls": "pathslicing", | ||||
"args": { | |||||
"root": "root", | "root": "root", | ||||
"slicing": "slicing", | "slicing": "slicing", | ||||
}, | |||||
"client_max_size": "10", | "client_max_size": "10", | ||||
} | } | ||||
} | } | ||||
for key in ("root", "slicing"): | for key in ("root", "slicing"): | ||||
c = copy.deepcopy(config) | c = copy.deepcopy(config) | ||||
c["objstorage"]["args"].pop(key) | c["objstorage"].pop(key) | ||||
config_path = prepare_config_file(tmpdir, c) | config_path = prepare_config_file(tmpdir, c) | ||||
with pytest.raises(KeyError, match=f"missing {key} config entry"): | with pytest.raises(KeyError, match=f"missing {key} config entry"): | ||||
load_and_check_config(config_path) | load_and_check_config(config_path) | ||||
@pytest.mark.parametrize( | @pytest.mark.parametrize( | ||||
"config", | "config", | ||||
[ | [ | ||||
pytest.param( | pytest.param( | ||||
{ | { | ||||
"objstorage": { | "objstorage": { | ||||
"cls": "pathslicing", | "cls": "pathslicing", | ||||
"args": {"root": "root", "slicing": "slicing"}, | "root": "root", | ||||
"slicing": "slicing", | |||||
} | } | ||||
}, | }, | ||||
id="pathslicing-bw-compat", | id="pathslicing-bw-compat", | ||||
), | ), | ||||
pytest.param( | pytest.param( | ||||
{ | { | ||||
"objstorage": { | "objstorage": { | ||||
"cls": "pathslicing", | "cls": "pathslicing", | ||||
"root": "root", | "root": "root", | ||||
"slicing": "slicing", | "slicing": "slicing", | ||||
} | } | ||||
}, | }, | ||||
id="pathslicing", | id="pathslicing", | ||||
), | ), | ||||
pytest.param( | pytest.param( | ||||
{"client_max_size": "10", "objstorage": {"cls": "memory", "args": {}}}, | {"client_max_size": "10", "objstorage": {"cls": "memory"}}, | ||||
id="empty-args-bw-compat", | id="empty-args-bw-compat", | ||||
), | ), | ||||
pytest.param( | pytest.param( | ||||
{"client_max_size": "10", "objstorage": {"cls": "memory"}}, id="empty-args" | {"client_max_size": "10", "objstorage": {"cls": "memory"}}, id="empty-args" | ||||
), | ), | ||||
pytest.param( | pytest.param( | ||||
{ | { | ||||
"objstorage": { | "objstorage": { | ||||
Show All 12 Lines |