self = <swh.storage.tests.test_api_client.TestStorageApi object at 0x7f1891ba5eb8>
swh_storage = <RemoteStorage url=mock://example.com/>
sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7f189237c240>
def test_extid_version_behavior(self, swh_storage, sample_data):
ids = [
revision.id
for revision in sample_data.revisions
if revision.type.value == "git"
]
# Insert extids with several different versions
extids = [
ExtID(
extid=extid,
extid_type="git",
extid_version=0,
target=CoreSWHID(object_id=extid, object_type=ObjectType.REVISION,),
)
for extid in ids
] + [
ExtID(
extid=extid,
extid_type="git",
extid_version=1,
target=CoreSWHID(object_id=extid, object_type=ObjectType.REVISION,),
)
for extid in ids
]
swh_storage.extid_add(extids)
# Check that both versions get returned
for git_id in ids:
objs = swh_storage.extid_get_from_extid("git", [git_id])
assert len(objs) == 2
assert set(obj.extid_version for obj in objs) == {0, 1}
for swhid in ids:
objs = swh_storage.extid_get_from_target(ObjectType.REVISION, [swhid])
assert len(objs) == 2
assert set(obj.extid_version for obj in objs) == {0, 1}
for version in [0, 1]:
for git_id in ids:
objs = swh_storage.extid_get_from_extid(
"git", [git_id], version=version
)
assert len(objs) == 1
assert objs[0].extid_version == version
for swhid in ids:
objs = swh_storage.extid_get_from_target(
ObjectType.REVISION,
[swhid],
extid_version=version,
extid_type="git",
)
assert len(objs) == 1
assert objs[0].extid_version == version
assert objs[0].extid_type == "git"
# Other edge cases
with pytest.raises(ValueError, match="both extid_type and extid_version"):
swh_storage.extid_get_from_target(
> ObjectType.REVISION, [ids[0]], extid_version=0
)
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py:1398:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:181: in meth_
return self.post(meth._endpoint_path, post_data)
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:278: in post
return self._decode_response(response)
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:354: in _decode_response
self.raise_for_status(response)
.tox/py3/lib/python3.7/site-packages/swh/storage/api/client.py:29: in raise_for_status
super().raise_for_status(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <RemoteStorage url=mock://example.com/>, response = <Response [500]>
def raise_for_status(self, response) -> None:
"""check response HTTP status code and raise an exception if it denotes an
error; do nothing otherwise
"""
status_code = response.status_code
status_class = response.status_code // 100
if status_code == 404:
raise RemoteException(payload="404 not found", response=response)
exception = None
# TODO: only old servers send pickled error; stop trying to unpickle
# after they are all upgraded
try:
if status_class == 4:
data = self._decode_response(response, check_status=False)
if isinstance(data, dict):
# TODO: remove "exception" key check once all servers
# are using new schema
exc_data = data["exception"] if "exception" in data else data
for exc_type in self.reraise_exceptions:
if exc_type.__name__ == exc_data["type"]:
exception = exc_type(*exc_data["args"])
break
else:
exception = RemoteException(payload=exc_data, response=response)
else:
exception = pickle.loads(data)
elif status_class == 5:
data = self._decode_response(response, check_status=False)
if "exception_pickled" in data:
exception = pickle.loads(data["exception_pickled"])
else:
# TODO: remove "exception" key check once all servers
# are using new schema
exc_data = data["exception"] if "exception" in data else data
exception = RemoteException(payload=exc_data, response=response)
except (TypeError, pickle.UnpicklingError):
raise RemoteException(payload=data, response=response)
if exception:
> raise exception from None
E swh.core.api.RemoteException: <RemoteException 500 ValueError: ['You must provide both extid_type and extid_version']>
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:344: RemoteException
TEST RESULT
TEST RESULT
- Run At
- Sep 14 2021, 7:17 PM