self = <swh.storage.tests.test_api_client.TestStorageApi object at 0x7fbaa0cd47f0>
swh_storage = <RemoteStorage url=mock://example.com/>
sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7fbaa07cb470>
def test_directory_add(self, swh_storage, sample_data):
content = sample_data.content
directory = sample_data.directories[1]
assert directory.entries[0].target == content.sha1_git
swh_storage.content_add([content])
init_missing = list(swh_storage.directory_missing([directory.id]))
assert [directory.id] == init_missing
actual_result = swh_storage.directory_add([directory])
assert actual_result == {"directory:add": 1}
assert ("directory", directory) in list(
swh_storage.journal_writer.journal.objects
)
actual_data = list(swh_storage.directory_ls(directory.id))
expected_data = list(transform_entries(swh_storage, directory))
for data in actual_data:
assert data in expected_data
after_missing = list(swh_storage.directory_missing([directory.id]))
assert after_missing == []
if not isinstance(swh_storage, CassandraStorage):
swh_storage.refresh_stat_counters()
> assert swh_storage.stat_counters()["directory"] == 1
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py:713:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/storage/api/client.py:51: in stat_counters
return self.get("stat/counters")
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:294: in get
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 NotImplementedError: []>
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:344: RemoteException
TEST RESULT
TEST RESULT
- Run At
- Aug 27 2021, 11:57 AM