diff --git a/requirements-swh.txt b/requirements-swh.txt --- a/requirements-swh.txt +++ b/requirements-swh.txt @@ -2,5 +2,5 @@ swh.model >= 0.0.15 swh.objstorage >= 0.0.43 swh.scheduler >= 0.0.47 -swh.storage >= 0.0.189 +swh.storage >= 0.2.0 swh.journal >= 0.1.0 diff --git a/swh/indexer/tests/test_origin_head.py b/swh/indexer/tests/test_origin_head.py --- a/swh/indexer/tests/test_origin_head.py +++ b/swh/indexer/tests/test_origin_head.py @@ -6,8 +6,10 @@ import unittest from datetime import datetime, timezone +from swh.model.model import OriginVisitStatus from swh.indexer.origin_head import OriginHeadIndexer from swh.indexer.tests.utils import BASE_TEST_CONFIG, fill_storage +from swh.storage.utils import now ORIGIN_HEAD_CONFIG = { **BASE_TEST_CONFIG, @@ -67,9 +69,14 @@ } ] ) - self.indexer.storage.origin_visit_update( - origin_url, visit.visit, status="partial", snapshot=b"foo" + visit_status = OriginVisitStatus( + origin=origin_url, + visit=visit.visit, + date=now(), + status="partial", + snapshot=b"foo", ) + self.indexer.storage.origin_visit_status_add([visit_status]) self.indexer.run([origin_url]) self.assertEqual(self.indexer.results, []) @@ -99,9 +106,14 @@ } ] ) - self.indexer.storage.origin_visit_update( - origin_url, visit.visit, status="full", snapshot=b"foo" + visit_status = OriginVisitStatus( + origin=origin_url, + visit=visit.visit, + date=now(), + status="full", + snapshot=b"foo", ) + self.indexer.storage.origin_visit_status_add([visit_status]) self.indexer.run(["https://pypi.org/project/abcdef/"]) self.assertEqual(self.indexer.results, []) diff --git a/swh/indexer/tests/utils.py b/swh/indexer/tests/utils.py --- a/swh/indexer/tests/utils.py +++ b/swh/indexer/tests/utils.py @@ -3,7 +3,6 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -import datetime import abc import functools import random @@ -14,6 +13,8 @@ from swh.model import hashutil from swh.model.hashutil import hash_to_bytes, hash_to_hex +from swh.model.model import OriginVisitStatus +from swh.storage.utils import now from swh.indexer.storage import INDEXER_CFG_KEY @@ -508,15 +509,19 @@ visit_types[visit["url"]] = visit["type"] for snap in SNAPSHOTS: origin_url = snap["origin"] - now = datetime.datetime.now(tz=datetime.timezone.utc) visit = storage.origin_visit_add( - origin_url, date=now, type=visit_types[origin_url] + origin_url, date=now(), type=visit_types[origin_url] ) snap_id = snap.get("id") or bytes([random.randint(0, 255) for _ in range(32)]) storage.snapshot_add([{"id": snap_id, "branches": snap["branches"]}]) - storage.origin_visit_update( - origin_url, visit.visit, status="full", snapshot=snap_id + visit_status = OriginVisitStatus( + origin=origin_url, + visit=visit.visit, + date=now(), + status="full", + snapshot=snap_id, ) + storage.origin_visit_status_add([visit_status]) storage.revision_add(REVISIONS) contents = []