self = <swh.storage.tests.test_cassandra.TestCassandraStorage object at 0x7f55181b70f0>
swh_storage = <swh.storage.validate.ValidatingProxyStorage object at 0x7f54d80a0ac8>
def test_origin_visit_status_add(self, swh_storage):
"""Correct origin visit statuses should add a new visit status
"""
origin1 = Origin.from_dict(data.origin2)
origin2 = Origin(url="new-origin")
swh_storage.origin_add([origin1, origin2])
ov1, ov2 = swh_storage.origin_visit_add(
[
OriginVisit(
origin=origin1.url, date=data.date_visit1, type=data.type_visit1,
),
OriginVisit(
origin=origin2.url, date=data.date_visit2, type=data.type_visit2,
),
]
)
ovs1 = OriginVisitStatus(
origin=origin1.url,
visit=ov1.visit,
date=data.date_visit1,
status="created",
snapshot=None,
)
ovs2 = OriginVisitStatus(
origin=origin2.url,
visit=ov2.visit,
date=data.date_visit2,
status="created",
snapshot=None,
)
snapshot_id = data.snapshot["id"]
date_visit_now = now()
visit_status1 = OriginVisitStatus(
origin=ov1.origin,
visit=ov1.visit,
date=date_visit_now,
status="full",
snapshot=snapshot_id,
)
date_visit_now = now()
visit_status2 = OriginVisitStatus(
origin=ov2.origin,
visit=ov2.visit,
date=date_visit_now,
status="ongoing",
snapshot=None,
metadata={"intrinsic": "something"},
)
> swh_storage.origin_visit_status_add([visit_status1, visit_status2])
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_storage.py:1846:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/storage.py:844: in origin_visit_status_add
self._origin_visit_status_add(visit_status)
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/storage.py:832: in _origin_visit_status_add
self._cql_runner.origin_visit_status_add_one(visit_status)
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/cql.py:106: in newf
self, *args, **kwargs, statement=self._prepared_statements[f.__name__]
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/cql.py:782: in origin_visit_status_add_one
metadata = json.dumps(visit_update.metadata)
/usr/lib/python3.7/json/__init__.py:231: in dumps
return _default_encoder.encode(obj)
/usr/lib/python3.7/json/encoder.py:199: in encode
chunks = self.iterencode(o, _one_shot=True)
/usr/lib/python3.7/json/encoder.py:257: in iterencode
return _iterencode(o, 0)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <json.encoder.JSONEncoder object at 0x7f5583d10cc0>
o = <swh.model.collections.ImmutableDict object at 0x7f55182bbeb8>
def default(self, o):
"""Implement this method in a subclass such that it returns
a serializable object for ``o``, or calls the base implementation
(to raise a ``TypeError``).
For example, to support arbitrary iterators, you could
implement default like this::
def default(self, o):
try:
iterable = iter(o)
except TypeError:
pass
else:
return list(iterable)
# Let the base class default method raise the TypeError
return JSONEncoder.default(self, o)
"""
> raise TypeError(f'Object of type {o.__class__.__name__} '
f'is not JSON serializable')
E TypeError: Object of type ImmutableDict is not JSON serializable
/usr/lib/python3.7/json/encoder.py:179: TypeError
TEST RESULT
TEST RESULT
- Run At
- Jul 9 2020, 10:30 AM