Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_server.py
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | def test_load_and_check_config_inexistent_file(): | ||||
expected_error = f"Configuration file {config_path} does not exist" | expected_error = f"Configuration file {config_path} does not exist" | ||||
with pytest.raises(FileNotFoundError, match=expected_error): | with pytest.raises(FileNotFoundError, match=expected_error): | ||||
load_and_check_config(config_path) | load_and_check_config(config_path) | ||||
def test_load_and_check_config_wrong_configuration(tmpdir): | def test_load_and_check_config_wrong_configuration(tmpdir): | ||||
"""Wrong configuration raises""" | """Wrong configuration raises""" | ||||
config_path = prepare_config_file(tmpdir, "something: useless") | config_path = prepare_config_file(tmpdir, "something: useless") | ||||
with pytest.raises(KeyError, match="Missing '%storage' configuration"): | with pytest.raises(KeyError, match="Missing 'storage' configuration"): | ||||
load_and_check_config(config_path) | load_and_check_config(config_path) | ||||
def test_load_and_check_config_local_config_fine(tmpdir): | def test_load_and_check_config_local_config_fine(tmpdir): | ||||
"""'local' complete configuration is fine""" | """'local' complete configuration is fine""" | ||||
config = {"storage": {"cls": "local", "db": "db", "objstorage": "something",}} | config = {"storage": {"cls": "local", "db": "db", "objstorage": "something",}} | ||||
config_path = prepare_config_file(tmpdir, config) | config_path = prepare_config_file(tmpdir, config) | ||||
cfg = load_and_check_config(config_path) | cfg = load_and_check_config(config_path) | ||||
assert cfg == config | assert cfg == config |