Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_retry.py
# Copyright (C) 2020 The Software Heritage developers | # Copyright (C) 2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import psycopg2 | import psycopg2 | ||||
import pytest | import pytest | ||||
from typing import Dict | from typing import Dict | ||||
from unittest.mock import call | from unittest.mock import call | ||||
from swh.storage import HashCollision | from swh.storage import HashCollision, get_storage | ||||
from swh.storage.exc import StorageArgumentException | from swh.storage.exc import StorageArgumentException | ||||
from swh.storage.retry import RetryingProxyStorage | |||||
@pytest.fixture | @pytest.fixture | ||||
def swh_storage(): | def swh_storage(): | ||||
return RetryingProxyStorage(storage={ | storage_config = { | ||||
'cls': 'validate', | 'cls': 'pipeline', | ||||
'storage': { | 'steps': [ | ||||
'cls': 'memory' | {'cls': 'validate'}, | ||||
{'cls': 'retry'}, | |||||
{'cls': 'memory'}, | |||||
] | |||||
} | } | ||||
}) | return get_storage(**storage_config) | ||||
def test_retrying_proxy_storage_content_add(swh_storage, sample_data): | def test_retrying_proxy_storage_content_add(swh_storage, sample_data): | ||||
"""Standard content_add works as before | """Standard content_add works as before | ||||
""" | """ | ||||
sample_content = sample_data['content'][0] | sample_content = sample_data['content'][0] | ||||
▲ Show 20 Lines • Show All 882 Lines • Show Last 20 Lines |