@contextlib.contextmanager
def convert_validation_exceptions():
"""Catches validation errors arguments, and re-raises a
StorageArgumentException."""
try:
> yield
.tox/py3/lib/python3.7/site-packages/swh/storage/validate.py:38:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.storage.validate.ValidatingProxyStorage object at 0x7f1b743093c8>
revisions = [b'p&\xb7\xc1\xa2\xafVR\x1e\x95\x1c\x01\xed \xf2U\xfa\x05B8']
def revision_get(
self, revisions: Iterable[bytes]
) -> Generator[Optional[Dict], None, None]:
rev_dicts = self.storage.revision_get(revisions)
with convert_validation_exceptions():
> for rev_dict in rev_dicts:
.tox/py3/lib/python3.7/site-packages/swh/storage/validate.py:87:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.storage.cassandra.storage.CassandraStorage object at 0x7f1b5413bd30>
revisions = [b'p&\xb7\xc1\xa2\xafVR\x1e\x95\x1c\x01\xed \xf2U\xfa\x05B8']
def revision_get(self, revisions):
rows = self._cql_runner.revision_get(revisions)
revs = {}
for row in rows:
# TODO: use a single query to get all parents?
# (it might have lower latency, but requires more code and more
# bandwidth, because revision id would be part of each returned
# row)
parent_rows = self._cql_runner.revision_parent_get(row.id)
# parent_rank is the clustering key, so results are already
# sorted by rank.
parents = [row.parent_id for row in parent_rows]
> rev = revision_from_db(row, parents=parents)
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/storage.py:462:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
db_revision = Row(id=b'p&\xb7\xc1\xa2\xafVR\x1e\x95\x1c\x01\xed \xf2U\xfa\x05B8', author=Person(fullname=b'Roberto Dicosmo <roberto@...73\xff7\xc3\xa95', message=b'a simple revision with no parents this time', metadata='null', synthetic=True, type='git')
parents = []
def revision_from_db(db_revision: Row, parents: Tuple[Sha1Git]) -> Revision:
revision = db_revision._asdict() # type: ignore
metadata = json.loads(revision.pop("metadata", None))
if metadata and "extra_headers" in metadata:
extra_headers = db_to_git_headers(metadata["extra_headers"])
metadata["extra_headers"] = extra_headers
return Revision(
parents=parents,
type=RevisionType(revision.pop("type")),
metadata=metadata,
> **revision,
)
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/converters.py:51:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Revision(message=b'a simple revision with no parents this time', author=Person(fullname=b'Roberto Dicosmo <roberto@exa...7\xc3\xa95', synthetic=True, metadata=None, parents=[], id=b'p&\xb7\xc1\xa2\xafVR\x1e\x95\x1c\x01\xed \xf2U\xfa\x05B8')
message = b'a simple revision with no parents this time'
author = Person(fullname=b'Roberto Dicosmo <roberto@example.com>', name=b'Roberto Dicosmo', email=b'roberto@example.com')
committer = Person(fullname=b'tony <ar@dumont.fr>', name=b'tony', email=b'ar@dumont.fr')
date = TimestampWithTimezone(timestamp=Timestamp(seconds=1234567843, microseconds=220000), offset=-720, negative_utc=False)
committer_date = TimestampWithTimezone(timestamp=Timestamp(seconds=1127351742, microseconds=0), offset=0, negative_utc=False)
type = <RevisionType.GIT: 'git'>
directory = b'4\x013B2S1\x000\xf51\xe62\xa73\xff7\xc3\xa95', synthetic = True
metadata = None, parents = []
id = b'p&\xb7\xc1\xa2\xafVR\x1e\x95\x1c\x01\xed \xf2U\xfa\x05B8'
def __init__(self, message, author, committer, date, committer_date, type, directory, synthetic, metadata=attr_dict['metadata'].default, parents=attr_dict['parents'].default, id=attr_dict['id'].default):
_inst_dict = self.__dict__
_inst_dict['message'] = message
_inst_dict['author'] = author
_inst_dict['committer'] = committer
_inst_dict['date'] = date
_inst_dict['committer_date'] = committer_date
_inst_dict['type'] = type
_inst_dict['directory'] = directory
_inst_dict['synthetic'] = synthetic
_inst_dict['metadata'] = metadata
_inst_dict['parents'] = parents
_inst_dict['id'] = id
if _config._run_validators is True:
__attr_validator_message(self, __attr_message, self.message)
__attr_validator_author(self, __attr_author, self.author)
__attr_validator_committer(self, __attr_committer, self.committer)
__attr_validator_date(self, __attr_date, self.date)
__attr_validator_committer_date(self, __attr_committer_date, self.committer_date)
__attr_validator_type(self, __attr_type, self.type)
__attr_validator_directory(self, __attr_directory, self.directory)
__attr_validator_synthetic(self, __attr_synthetic, self.synthetic)
__attr_validator_metadata(self, __attr_metadata, self.metadata)
> __attr_validator_parents(self, __attr_parents, self.parents)
<attrs generated init swh.model.model.Revision>:24:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
instance = Revision(message=b'a simple revision with no parents this time', author=Person(fullname=b'Roberto Dicosmo <roberto@exa...7\xc3\xa95', synthetic=True, metadata=None, parents=[], id=b'p&\xb7\xc1\xa2\xafVR\x1e\x95\x1c\x01\xed \xf2U\xfa\x05B8')
attribute = Attribute(name='parents', default=(), validator=<function type_validator.<locals>._validator at 0x7f1b7db682f0>, repr=...er=True, hash=None, init=True, metadata=mappingproxy({}), type=typing.Tuple[bytes, ...], converter=None, kw_only=False)
field = []
def _validator(instance, attribute, field):
if not empty_ok and not field:
raise EmptyError(field, attribute)
> _validate_elements(attribute, field, attribute.type)
.tox/py3/lib/python3.7/site-packages/attrs_strict/_type_validation.py:63:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
attribute = Attribute(name='parents', default=(), validator=<function type_validator.<locals>._validator at 0x7f1b7db682f0>, repr=...er=True, hash=None, init=True, metadata=mappingproxy({}), type=typing.Tuple[bytes, ...], converter=None, kw_only=False)
value = [], expected_type = typing.Tuple[bytes, ...]
def _validate_elements(attribute, value, expected_type):
if expected_type is None:
return
base_type = _get_base_type(expected_type)
if base_type == typing.Any:
return
if base_type != typing.Union and not isinstance( # type: ignore
value, base_type
):
> raise AttributeTypeError(value, attribute)
E attrs_strict._error.AttributeTypeError: parents must be typing.Tuple[bytes, ...] (got [] that is a <class 'list'>)
.tox/py3/lib/python3.7/site-packages/attrs_strict/_type_validation.py:80: AttributeTypeError
During handling of the above exception, another exception occurred:
self = <swh.storage.tests.test_cassandra.TestCassandraStorage object at 0x7f1af46b4f28>
swh_storage = <swh.storage.validate.ValidatingProxyStorage object at 0x7f1b743093c8>
def test_revision_get_no_parents(self, swh_storage):
swh_storage.revision_add([data.revision3])
> get = list(swh_storage.revision_get([data.revision3["id"]]))
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_storage.py:1110:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/storage/validate.py:87: in revision_get
for rev_dict in rev_dicts:
/usr/lib/python3.7/contextlib.py:130: in __exit__
self.gen.throw(type, value, traceback)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@contextlib.contextmanager
def convert_validation_exceptions():
"""Catches validation errors arguments, and re-raises a
StorageArgumentException."""
try:
yield
except tuple(VALIDATION_EXCEPTIONS) as e:
> raise StorageArgumentException(str(e))
E swh.storage.exc.StorageArgumentException: parents must be typing.Tuple[bytes, ...] (got [] that is a <class 'list'>)
.tox/py3/lib/python3.7/site-packages/swh/storage/validate.py:40: StorageArgumentException
TEST RESULT
TEST RESULT
- Run At
- Jun 4 2020, 10:56 AM