config_ok = {'storage': {'cls': 'remote', 'url': 'mock://storage-url'}, 'vault': {'cls': 'remote', 'url': 'mock://vault-backend'}}
tmp_path = PosixPath('/tmp/pytest-of-jenkins/pytest-0/test_get_cooker_nominal_config2')
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f1bb8a822e8>
@pytest.mark.parametrize(
"config_ok",
[
{
"vault": {
"cls": "remote",
"args": {
"url": "mock://vault-backend",
"storage": {"cls": "remote", "url": "mock://storage-url"},
},
}
},
{
"vault": {"cls": "remote", "args": {"url": "mock://vault-backend",},},
"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):
"""Correct configuration should allow the instantiation of the cookers
"""
for cooker_type in COOKER_TYPES.keys():
write_config_to_env(config_ok, tmp_path, monkeypatch)
> cooker = get_cooker(cooker_type, TEST_HEX_ID)
.tox/py3/lib/python3.7/site-packages/swh/vault/tests/test_init_cookers.py:109:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
obj_type = 'directory', obj_id = '4a4b9771542143cf070386f86b4b92d42966bdbc'
def get_cooker(obj_type: str, obj_id: str):
"""Instantiate a cooker class of type obj_type.
Returns:
Cooker class in charge of cooking the obj_type with id obj_id.
Raises:
ValueError in case of a missing top-level vault key configuration or a storage
key.
EnvironmentError in case the vault configuration reference a non remote class.
"""
if "SWH_CONFIG_FILENAME" in os.environ:
cfg = read_config(os.environ["SWH_CONFIG_FILENAME"], DEFAULT_CONFIG)
else:
cfg = load_named_config(DEFAULT_CONFIG_PATH, DEFAULT_CONFIG)
cooker_cls = get_cooker_cls(obj_type)
cfg = check_config(cfg)
vcfg = cfg["vault"]
storage = get_storage(**vcfg.pop("storage"))
backend = get_vault(**vcfg)
try:
from swh.graph.client import RemoteGraphClient # optional dependency
> graph: Optional[RemoteGraphClient] = RemoteGraphClient(**vcfg["graph"])
E KeyError: 'graph'
.tox/py3/lib/python3.7/site-packages/swh/vault/cookers/__init__.py:96: KeyError
TEST RESULT
TEST RESULT
- Run At
- Jun 28 2021, 5:37 PM