Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/swh_model_data.py
# Copyright (C) 2019-2021 The Software Heritage developers | # Copyright (C) 2019-2021 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import datetime | import datetime | ||||
from typing import Dict, Sequence | from typing import Dict, Sequence | ||||
import attr | import attr | ||||
from swh.model.hashutil import MultiHash, hash_to_bytes | from swh.model.hashutil import MultiHash, hash_to_bytes | ||||
from swh.model.identifiers import ExtendedSWHID | from swh.model.identifiers import CoreSWHID, ExtendedSWHID | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
BaseModel, | BaseModel, | ||||
Content, | Content, | ||||
Directory, | Directory, | ||||
DirectoryEntry, | DirectoryEntry, | ||||
ExtID, | |||||
MetadataAuthority, | MetadataAuthority, | ||||
MetadataAuthorityType, | MetadataAuthorityType, | ||||
MetadataFetcher, | MetadataFetcher, | ||||
ObjectType, | ObjectType, | ||||
Origin, | Origin, | ||||
OriginVisit, | OriginVisit, | ||||
OriginVisitStatus, | OriginVisitStatus, | ||||
Person, | Person, | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | Revision( | ||||
type=RevisionType.MERCURIAL, | type=RevisionType.MERCURIAL, | ||||
directory=b"\x02" * 20, | directory=b"\x02" * 20, | ||||
synthetic=False, | synthetic=False, | ||||
metadata=None, | metadata=None, | ||||
parents=(), | parents=(), | ||||
extra_headers=((b"foo", b"bar"),), | extra_headers=((b"foo", b"bar"),), | ||||
), | ), | ||||
] | ] | ||||
EXTIDS = [ | |||||
ExtID( | |||||
extid_type="git256", | |||||
extid=b"\x03" * 32, | |||||
target=CoreSWHID.from_string(str(REVISIONS[0].swhid())), | |||||
), | |||||
ExtID( | |||||
extid_type="hg", | |||||
extid=b"\x04" * 20, | |||||
target=CoreSWHID.from_string(str(REVISIONS[1].swhid())), | |||||
), | |||||
vlorentz: ;) | |||||
] | |||||
RELEASES = [ | RELEASES = [ | ||||
Release( | Release( | ||||
id=hash_to_bytes("8059dc4e17fcd0e51ca3bcd6b80f4577d281fd08"), | id=hash_to_bytes("8059dc4e17fcd0e51ca3bcd6b80f4577d281fd08"), | ||||
name=b"v0.0.1", | name=b"v0.0.1", | ||||
date=TimestampWithTimezone( | date=TimestampWithTimezone( | ||||
timestamp=Timestamp(seconds=1234567890, microseconds=0,), | timestamp=Timestamp(seconds=1234567890, microseconds=0,), | ||||
offset=120, | offset=120, | ||||
negative_utc=False, | negative_utc=False, | ||||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | RawExtrinsicMetadata( | ||||
metadata=b'{"foo": "bar"}', | metadata=b'{"foo": "bar"}', | ||||
), | ), | ||||
] | ] | ||||
TEST_OBJECTS: Dict[str, Sequence[BaseModel]] = { | TEST_OBJECTS: Dict[str, Sequence[BaseModel]] = { | ||||
"content": CONTENTS, | "content": CONTENTS, | ||||
"directory": DIRECTORIES, | "directory": DIRECTORIES, | ||||
"extid": EXTIDS, | |||||
"metadata_authority": METADATA_AUTHORITIES, | "metadata_authority": METADATA_AUTHORITIES, | ||||
"metadata_fetcher": METADATA_FETCHERS, | "metadata_fetcher": METADATA_FETCHERS, | ||||
"origin": ORIGINS, | "origin": ORIGINS, | ||||
"origin_visit": ORIGIN_VISITS, | "origin_visit": ORIGIN_VISITS, | ||||
"origin_visit_status": ORIGIN_VISIT_STATUSES, | "origin_visit_status": ORIGIN_VISIT_STATUSES, | ||||
"raw_extrinsic_metadata": RAW_EXTRINSIC_METADATA, | "raw_extrinsic_metadata": RAW_EXTRINSIC_METADATA, | ||||
"release": RELEASES, | "release": RELEASES, | ||||
"revision": REVISIONS, | "revision": REVISIONS, | ||||
"snapshot": SNAPSHOTS, | "snapshot": SNAPSHOTS, | ||||
"skipped_content": SKIPPED_CONTENTS, | "skipped_content": SKIPPED_CONTENTS, | ||||
} | } |
;)