Page MenuHomeSoftware Heritage

Jenkins > .tox.py3.lib.python3.7.site-packages.swh.storage.tests.test_storage.TestStorage::test_origin_visit_status_add
Failed

TEST RESULT

Run At
Jul 9 2020, 10:49 AM
Details
self = <swh.storage.tests.test_storage.TestStorage object at 0x7f1b967c0be0> swh_storage = <swh.storage.validate.ValidatingProxyStorage object at 0x7f1b967c0630> 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/metrics.py:24: in d return f(*a, **kw) .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/storage.py:864: in origin_visit_status_add self._origin_visit_status_add(visit_status, db, cur) .tox/py3/lib/python3.7/site-packages/swh/storage/storage.py:847: in _origin_visit_status_add db.origin_visit_status_add(visit_status, cur=cur) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <swh.storage.db.Db object at 0x7f1b9674a198> visit_status = OriginVisitStatus(origin='new-origin', visit=1, date=datetime.datetime(2020, 7, 9, 8, 47, 37, 215487, tzinfo=datetime.timezone.utc), status='ongoing', snapshot=None, metadata=<swh.model.collections.ImmutableDict object at 0x7f1b9674a160>) cur = <cursor object at 0x7f1d78f47dd8; closed: -1> def origin_visit_status_add( self, visit_status: OriginVisitStatus, cur=None ) -> None: """Add new origin visit status """ assert self.origin_visit_status_cols[0] == "origin" assert self.origin_visit_status_cols[-1] == "metadata" cols = self.origin_visit_status_cols[1:-1] cur = self._cursor(cur) cur.execute( f"WITH origin_id as (select id from origin where url=%s) " f"INSERT INTO origin_visit_status " f"(origin, {', '.join(cols)}, metadata) " f"VALUES ((select id from origin_id), " f"{', '.join(['%s']*len(cols))}, %s) " f"ON CONFLICT (origin, visit, date) do nothing", [visit_status.origin] + [getattr(visit_status, key) for key in cols] > + [jsonize(visit_status.metadata)], ) E psycopg2.ProgrammingError: can't adapt type 'ImmutableDict' .tox/py3/lib/python3.7/site-packages/swh/storage/db.py:477: ProgrammingError