monkeypatch_sleep = <_pytest.monkeypatch.MonkeyPatch object at 0x7f019193ba90>
swh_storage = <swh.storage.validate.ValidatingProxyStorage object at 0x7f019193bda0>
sample_data = {'authority': [{'metadata': {'location': 'France'}, 'type': 'deposit', 'url': 'http://hal.inria.example.com/'}], 'cont...384>, 'target': b'12345678901234567890', 'type': 'dir'}), 'id': b'4\x013B2S1\x000\xf51\xe62\xa73\xff7\xc3\xa90'}], ...}
mocker = <pytest_mock.plugin.MockFixture object at 0x7f019193b278>
fake_hash_collision = HashCollision('sha1', '38762cf7f55934b34d179ae6a4c80cadccbb7f0a', [])
def test_retrying_proxy_swh_storage_origin_visit_add_retry(
monkeypatch_sleep, swh_storage, sample_data, mocker, fake_hash_collision
):
"""Multiple retries for hash collision and psycopg2 error but finally ok
"""
sample_origin = sample_data["origin"][1]
origin_url = swh_storage.origin_add_one(sample_origin)
mock_memory = mocker.patch("swh.storage.in_memory.InMemoryStorage.origin_visit_add")
mock_memory.side_effect = [
# first try goes ko
fake_hash_collision,
# second try goes ko
psycopg2.IntegrityError("origin already inserted"),
# ok then!
{"origin": origin_url, "visit": 1},
]
origin = list(swh_storage.origin_visit_get(origin_url))
assert not origin
> r = swh_storage.origin_visit_add(origin_url, date_visit1, "git")
E TypeError: origin_visit_add() takes 2 positional arguments but 4 were given
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_retry.py:389: TypeError
TEST RESULT
TEST RESULT
- Run At
- Jun 11 2020, 3:42 PM