Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/tests/test_init_cookers.py
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | [ | ||||
EnvironmentError, | EnvironmentError, | ||||
"This vault backend can only be a 'remote' configuration", | "This vault backend can only be a 'remote' configuration", | ||||
), | ), | ||||
( | ( | ||||
{"vault": {"cls": "remote", "args": {"missing-storage-key": ""}}}, | {"vault": {"cls": "remote", "args": {"missing-storage-key": ""}}}, | ||||
ValueError, | ValueError, | ||||
"invalid configuration: missing 'storage' config entry", | "invalid configuration: missing 'storage' config entry", | ||||
), | ), | ||||
({"vault": {"cls": "remote"}}, KeyError, "args",), | |||||
], | ], | ||||
) | ) | ||||
def test_get_cooker_config_ko( | def test_get_cooker_config_ko( | ||||
config_ko, exception_class, exception_msg, monkeypatch, tmp_path | config_ko, exception_class, exception_msg, monkeypatch, tmp_path | ||||
): | ): | ||||
"""Misconfigured cooker should fail the instantiation with exception message | """Misconfigured cooker should fail the instantiation with exception message | ||||
""" | """ | ||||
Show All 14 Lines | [ | ||||
"storage": {"cls": "remote", "url": "mock://storage-url"}, | "storage": {"cls": "remote", "url": "mock://storage-url"}, | ||||
}, | }, | ||||
} | } | ||||
}, | }, | ||||
{ | { | ||||
"vault": {"cls": "remote", "args": {"url": "mock://vault-backend",},}, | "vault": {"cls": "remote", "args": {"url": "mock://vault-backend",},}, | ||||
"storage": {"cls": "remote", "url": "mock://storage-url"}, | "storage": {"cls": "remote", "url": "mock://storage-url"}, | ||||
}, | }, | ||||
{ | |||||
"vault": {"cls": "remote", "url": "mock://vault-backend",}, | |||||
"storage": {"cls": "remote", "url": "mock://storage-url"}, | |||||
}, | |||||
], | ], | ||||
) | ) | ||||
def test_get_cooker_nominal(config_ok, tmp_path, monkeypatch): | def test_get_cooker_nominal(config_ok, tmp_path, monkeypatch): | ||||
"""Correct configuration should allow the instantiation of the cookers | """Correct configuration should allow the instantiation of the cookers | ||||
""" | """ | ||||
for cooker_type in COOKER_TYPES.keys(): | for cooker_type in COOKER_TYPES.keys(): | ||||
write_config_to_env(config_ok, tmp_path, monkeypatch) | write_config_to_env(config_ok, tmp_path, monkeypatch) | ||||
cooker = get_cooker(cooker_type, TEST_HEX_ID) | cooker = get_cooker(cooker_type, TEST_HEX_ID) | ||||
assert cooker is not None | assert cooker is not None | ||||
assert isinstance(cooker, COOKER_TYPES[cooker_type]) | assert isinstance(cooker, COOKER_TYPES[cooker_type]) |