data = b'\x82\x92\xa3foo\xa3git\x82\xc4\x07swhtype\xafscheduler_model\xc4\x01d\x89\xa3url\xa3foo\xaavisit_type\xa3git\xadlast...adlast_snapshot\xc4\x14\xff\xfc\xc0q\x0e\xb6\xcf\x9e\xfd[\x92\n\x84S\xe1\xe0qW\xbf\xff\xa8__type__\xb0OriginVisitStats'
extra_decoders = {'scheduler_model': <function <lambda> at 0x7fd10657b1e0>}
def msgpack_loads(data: bytes, extra_decoders=None) -> Any:
"""Read data as a msgpack stream.
.. Caution::
This function is used by swh.journal to decode the contents of the
journal. This function **must** be kept backwards-compatible.
"""
decoders = get_decoders(extra_decoders)
def ext_hook(code, data):
if code == MsgpackExtTypeCodes.LONG_INT.value:
return int.from_bytes(data, "big")
elif code == MsgpackExtTypeCodes.LONG_NEG_INT.value:
return -int.from_bytes(data, "big")
raise ValueError("Unknown msgpack extended code %s" % code)
def decode_types(obj):
# Support for current encodings
if set(obj.keys()) == {b"d", b"swhtype"}:
decoder = decoders.get(obj[b"swhtype"])
if decoder:
return decoder(obj[b"d"])
# Fallthrough
return obj
try:
try:
return msgpack.unpackb(
data,
raw=False,
object_hook=decode_types,
ext_hook=ext_hook,
> strict_map_key=False,
)
.tox/py3/lib/python3.7/site-packages/swh/core/api/serializers.py:292:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> ???
E TypeError: unhashable type: 'list'
msgpack/_unpacker.pyx:195: TypeError
During handling of the above exception, another exception occurred:
self = <swh.scheduler.tests.test_scheduler.TestScheduler object at 0x7fd1040932e8>
swh_scheduler = <RemoteScheduler url=mock://example.com/>
def test_origin_visit_stats_upsert_batch(self, swh_scheduler) -> None:
"""Batch upsert is ok"""
visit_stats = [
OriginVisitStats(
url="foo",
visit_type="git",
last_eventful=utcnow(),
last_uneventful=None,
last_failed=None,
last_notfound=None,
last_snapshot=hash_to_bytes("d81cc0710eb6cf9efd5b920a8453e1e07157b6cd"),
),
OriginVisitStats(
url="bar",
visit_type="git",
last_eventful=None,
last_uneventful=utcnow(),
last_notfound=None,
last_failed=None,
last_snapshot=hash_to_bytes("fffcc0710eb6cf9efd5b920a8453e1e07157bfff"),
),
]
swh_scheduler.origin_visit_stats_upsert(visit_stats)
visit_stats_dict = swh_scheduler.origin_visit_stats_get(
> [(vs.url, vs.visit_type) for vs in visit_stats]
)
.tox/py3/lib/python3.7/site-packages/swh/scheduler/tests/test_scheduler.py:954:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:355: in _decode_response
return decode_response(response, extra_decoders=self.extra_type_decoders)
.tox/py3/lib/python3.7/site-packages/swh/core/api/serializers.py:120: in decode_response
r = msgpack_loads(response.content, extra_decoders=extra_decoders)
.tox/py3/lib/python3.7/site-packages/swh/core/api/serializers.py:296: in msgpack_loads
data, raw=False, object_hook=decode_types, ext_hook=ext_hook
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> ???
E ValueError: list is not allowed for map key
msgpack/_unpacker.pyx:195: ValueError
TEST RESULT
TEST RESULT
- Run At
- Jan 20 2021, 12:53 PM