Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_retry.py
Show All 11 Lines | |||||
from swh.storage import HashCollision | from swh.storage import HashCollision | ||||
from swh.storage.exc import StorageArgumentException | from swh.storage.exc import StorageArgumentException | ||||
from swh.storage.retry import RetryingProxyStorage | from swh.storage.retry import RetryingProxyStorage | ||||
@pytest.fixture | @pytest.fixture | ||||
def swh_storage(): | def swh_storage(): | ||||
return RetryingProxyStorage(storage={'cls': 'memory'}) | return RetryingProxyStorage(storage={ | ||||
'cls': 'validate', | |||||
'storage': { | |||||
'cls': 'memory' | |||||
} | |||||
}) | |||||
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 189 Lines • ▼ Show 20 Lines | mock_memory.side_effect = StorageArgumentException( | ||||
'Refuse to add origin always!') | 'Refuse to add origin always!') | ||||
sample_origin = sample_data['origin'][0] | sample_origin = sample_data['origin'][0] | ||||
origin = swh_storage.origin_get(sample_origin) | origin = swh_storage.origin_get(sample_origin) | ||||
assert not origin | assert not origin | ||||
with pytest.raises(StorageArgumentException, match='Refuse to add'): | with pytest.raises(StorageArgumentException, match='Refuse to add'): | ||||
swh_storage.origin_add_one([sample_origin]) | swh_storage.origin_add_one(sample_origin) | ||||
assert mock_memory.call_count == 1 | assert mock_memory.call_count == 1 | ||||
def test_retrying_proxy_swh_storage_origin_visit_add(swh_storage, sample_data): | def test_retrying_proxy_swh_storage_origin_visit_add(swh_storage, sample_data): | ||||
"""Standard origin_visit_add works as before | """Standard origin_visit_add works as before | ||||
""" | """ | ||||
▲ Show 20 Lines • Show All 676 Lines • Show Last 20 Lines |