diff --git a/mypy.ini b/mypy.ini --- a/mypy.ini +++ b/mypy.ini @@ -17,6 +17,9 @@ [mypy-pytest.*] ignore_missing_imports = True +[mypy-iso8601.*] +ignore_missing_imports = True + [mypy-pytest_kafka.*] ignore_missing_imports = True diff --git a/requirements.txt b/requirements.txt --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ msgpack tenacity vcversioner +iso8601 diff --git a/swh/journal/serializers.py b/swh/journal/serializers.py --- a/swh/journal/serializers.py +++ b/swh/journal/serializers.py @@ -62,6 +62,12 @@ "origin": object_.origin, "date": str(object_.date), } + elif object_type == "origin_visit_status": + return { + "origin": object_.origin, + "visit": str(object_.visit), + "date": str(object_.date), + } else: raise ValueError("Unknown object type: %s." % object_type) diff --git a/swh/journal/tests/journal_data.py b/swh/journal/tests/journal_data.py --- a/swh/journal/tests/journal_data.py +++ b/swh/journal/tests/journal_data.py @@ -3,7 +3,9 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information +import copy import datetime +import iso8601 from typing import Any, Dict, List, Type @@ -16,6 +18,7 @@ Directory, Origin, OriginVisit, + OriginVisitStatus, Release, Revision, SkippedContent, @@ -28,6 +31,7 @@ Directory: "directory", Origin: "origin", OriginVisit: "origin_visit", + OriginVisitStatus: "origin_visit_status", Release: "release", Revision: "revision", SkippedContent: "skipped_content", @@ -191,6 +195,14 @@ ] +ORIGIN_VISIT_STATUSES = [] +for visit in ORIGIN_VISITS: + visit_status = copy.deepcopy(visit) + visit_status["date"] = iso8601.parse_date(visit["date"]) + visit_status.pop("type") + ORIGIN_VISIT_STATUSES.append(visit_status) + + DIRECTORIES = [ {"id": hash_to_bytes("4b825dc642cb6eb9a060e54bf8d69288fbee4904"), "entries": ()}, { @@ -253,6 +265,7 @@ "directory": DIRECTORIES, "origin": ORIGINS, "origin_visit": ORIGIN_VISITS, + "origin_visit_status": ORIGIN_VISIT_STATUSES, "release": RELEASES, "revision": REVISIONS, "snapshot": SNAPSHOTS, diff --git a/swh/journal/tests/test_pytest_plugin.py b/swh/journal/tests/test_pytest_plugin.py --- a/swh/journal/tests/test_pytest_plugin.py +++ b/swh/journal/tests/test_pytest_plugin.py @@ -56,6 +56,7 @@ "directory", "origin", "origin_visit", + "origin_visit_status", "release", "revision", "snapshot",