self = <swh.storage.tests.test_postgresql.TestStorage object at 0x7efe24f888d0>
swh_storage = <swh.storage.postgresql.storage.Storage object at 0x7efe4fc67198>
sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7efe1ca3a160>
def test_origin_metadata_add_duplicate(self, swh_storage, sample_data):
"""Duplicates should be silently updated."""
origin = sample_data.origin
fetcher = sample_data.metadata_fetcher
authority = sample_data.metadata_authority
origin_metadata, origin_metadata2 = sample_data.origin_metadata[:2]
assert swh_storage.origin_add([origin]) == {"origin:add": 1}
swh_storage.metadata_fetcher_add([fetcher])
swh_storage.metadata_authority_add([authority])
swh_storage.raw_extrinsic_metadata_add([origin_metadata, origin_metadata2])
swh_storage.raw_extrinsic_metadata_add([origin_metadata2, origin_metadata])
result = swh_storage.raw_extrinsic_metadata_get(
> Origin(origin.url).swhid(), authority
)
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py:4391:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/core/db/common.py:62: in _meth
return meth(self, *args, db=db, cur=cur, **kwargs)
.tox/py3/lib/python3.7/site-packages/swh/storage/postgresql/storage.py:1465: in raw_extrinsic_metadata_get
results.append(converters.db_to_raw_extrinsic_metadata(row))
.tox/py3/lib/python3.7/site-packages/swh/storage/postgresql/converters.py:326: in db_to_raw_extrinsic_metadata
directory=map_optional(CoreSWHID.from_string, row["directory"]),
<attrs generated init swh.model.model.RawExtrinsicMetadata>:18: in __init__
__attr_validator_target(self, __attr_target, self.target)
.tox/py3/lib/python3.7/site-packages/attrs_strict/_type_validation.py:105: in _validator
_validate_elements(attribute, field, attribute.type)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
attribute = Attribute(name='target', default=NOTHING, validator=<function type_validator.<locals>._validator at 0x7f0026b3a730>, r...xy({}), type=<class 'swh.model.swhids.ExtendedSWHID'>, converter=None, kw_only=False, inherited=False, on_setattr=None)
value = 'swh:1:ori:33abd4b4c5db79c7387673f71302750fd73e0645'
expected_type = <class 'swh.model.swhids.ExtendedSWHID'>
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 isinstance(base_type, (str, ForwardRef)):
# These base_types happen when you have string annotations and cannot
# be used in isinstance.
raise _StringAnnotationError()
elif base_type == Literal or base_type == type(Literal): # type: ignore
_handle_literal(attribute, value, expected_type)
elif base_type == typing.Union: # type: ignore
_handle_union(attribute, value, expected_type)
elif not isinstance(value, base_type):
> raise AttributeTypeError(value, attribute)
E attrs_strict._error.AttributeTypeError: target must be <class 'swh.model.swhids.ExtendedSWHID'> (got swh:1:ori:33abd4b4c5db79c7387673f71302750fd73e0645 that is a <class 'str'>)
.tox/py3/lib/python3.7/site-packages/attrs_strict/_type_validation.py:131: AttributeTypeError
TEST RESULT
TEST RESULT
- Run At
- Oct 7 2021, 11:31 AM