Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/storage_data.py
Show All 21 Lines | from swh.model.model import ( | ||||
Origin, | Origin, | ||||
OriginVisit, | OriginVisit, | ||||
Person, | Person, | ||||
RawExtrinsicMetadata, | RawExtrinsicMetadata, | ||||
Release, | Release, | ||||
Revision, | Revision, | ||||
RevisionType, | RevisionType, | ||||
SkippedContent, | SkippedContent, | ||||
Snapshot, | |||||
SnapshotBranch, | |||||
TargetType, | |||||
Timestamp, | Timestamp, | ||||
TimestampWithTimezone, | TimestampWithTimezone, | ||||
) | ) | ||||
class StorageData: | class StorageData: | ||||
def __getattr__(self, key): | def __getattr__(self, key): | ||||
try: | try: | ||||
▲ Show 20 Lines • Show All 396 Lines • ▼ Show 20 Lines | release3 = Release( | ||||
target=revision3.id, | target=revision3.id, | ||||
target_type=ObjectType.REVISION, | target_type=ObjectType.REVISION, | ||||
message=b"yet another synthetic release", | message=b"yet another synthetic release", | ||||
synthetic=True, | synthetic=True, | ||||
) | ) | ||||
releases = [release, release2, release3] | releases = [release, release2, release3] | ||||
snapshot = { | snapshot = Snapshot( | ||||
"id": hash_to_bytes("409ee1ff3f10d166714bc90581debfd0446dda57"), | id=hash_to_bytes("409ee1ff3f10d166714bc90581debfd0446dda57"), | ||||
"branches": { | branches={ | ||||
b"master": { | b"master": SnapshotBranch(target=revision.id, target_type=TargetType.REVISION,), | ||||
"target": hash_to_bytes("066b1b62dbfa033362092af468bf6cfabec230e7"), | |||||
"target_type": "revision", | |||||
}, | }, | ||||
}, | ) | ||||
} | |||||
empty_snapshot = { | empty_snapshot = Snapshot( | ||||
"id": hash_to_bytes("1a8893e6a86f444e8be8e7bda6cb34fb1735a00e"), | id=hash_to_bytes("1a8893e6a86f444e8be8e7bda6cb34fb1735a00e"), branches={}, | ||||
"branches": {}, | ) | ||||
} | |||||
complete_snapshot = Snapshot( | |||||
complete_snapshot = { | id=hash_to_bytes("a56ce2d81c190023bb99a3a36279307522cb85f6"), | ||||
"id": hash_to_bytes("a56ce2d81c190023bb99a3a36279307522cb85f6"), | branches={ | ||||
"branches": { | b"directory": SnapshotBranch( | ||||
b"directory": { | target=directory.id, target_type=TargetType.DIRECTORY, | ||||
"target": hash_to_bytes("1bd0e65f7d2ff14ae994de17a1e7fe65111dcad8"), | ), | ||||
"target_type": "directory", | b"directory2": SnapshotBranch( | ||||
}, | target=directory2.id, target_type=TargetType.DIRECTORY, | ||||
b"directory2": { | ), | ||||
"target": hash_to_bytes("1bd0e65f7d2ff14ae994de17a1e7fe65111dcad8"), | b"content": SnapshotBranch( | ||||
"target_type": "directory", | target=content.sha1_git, target_type=TargetType.CONTENT, | ||||
}, | ), | ||||
b"content": { | b"alias": SnapshotBranch(target=b"revision", target_type=TargetType.ALIAS,), | ||||
"target": hash_to_bytes("fe95a46679d128ff167b7c55df5d02356c5a1ae1"), | b"revision": SnapshotBranch( | ||||
"target_type": "content", | target=revision.id, target_type=TargetType.REVISION, | ||||
}, | ), | ||||
b"alias": {"target": b"revision", "target_type": "alias",}, | b"release": SnapshotBranch(target=release.id, target_type=TargetType.RELEASE,), | ||||
b"revision": { | b"snapshot": SnapshotBranch( | ||||
"target": hash_to_bytes("aafb16d69fd30ff58afdd69036a26047f3aebdc6"), | target=empty_snapshot.id, target_type=TargetType.SNAPSHOT, | ||||
"target_type": "revision", | ), | ||||
}, | |||||
b"release": { | |||||
"target": hash_to_bytes("7045404f3d1c54e6473c71bbb716529fbad4be24"), | |||||
"target_type": "release", | |||||
}, | |||||
b"snapshot": { | |||||
"target": hash_to_bytes("1a8893e6a86f444e8be8e7bda6cb34fb1735a00e"), | |||||
"target_type": "snapshot", | |||||
}, | |||||
b"dangling": None, | b"dangling": None, | ||||
}, | }, | ||||
} | ) | ||||
snapshots = (snapshot, empty_snapshot, complete_snapshot) | snapshots = [snapshot, empty_snapshot, complete_snapshot] | ||||
content_metadata = RawExtrinsicMetadata( | content_metadata = RawExtrinsicMetadata( | ||||
type=MetadataTargetType.CONTENT, | type=MetadataTargetType.CONTENT, | ||||
id=parse_swhid(f"swh:1:cnt:{hash_to_hex(content.sha1_git)}"), | id=parse_swhid(f"swh:1:cnt:{hash_to_hex(content.sha1_git)}"), | ||||
origin=origin.url, | origin=origin.url, | ||||
discovery_date=datetime.datetime( | discovery_date=datetime.datetime( | ||||
2015, 1, 1, 21, 0, 0, tzinfo=datetime.timezone.utc | 2015, 1, 1, 21, 0, 0, tzinfo=datetime.timezone.utc | ||||
), | ), | ||||
Show All 21 Lines | discovery_date=datetime.datetime( | ||||
2017, 1, 1, 22, 0, 0, tzinfo=datetime.timezone.utc | 2017, 1, 1, 22, 0, 0, tzinfo=datetime.timezone.utc | ||||
), | ), | ||||
authority=attr.evolve(metadata_authority2, metadata=None), | authority=attr.evolve(metadata_authority2, metadata=None), | ||||
fetcher=attr.evolve(metadata_fetcher2, metadata=None), | fetcher=attr.evolve(metadata_fetcher2, metadata=None), | ||||
format="yaml", | format="yaml", | ||||
metadata=b"foo: bar", | metadata=b"foo: bar", | ||||
origin=origin.url, | origin=origin.url, | ||||
visit=42, | visit=42, | ||||
snapshot=parse_swhid(f"swh:1:snp:{hash_to_hex(snapshot['id'])}"), | snapshot=parse_swhid(f"swh:1:snp:{hash_to_hex(snapshot.id)}"), | ||||
release=parse_swhid(f"swh:1:rel:{hash_to_hex(release.id)}"), | release=parse_swhid(f"swh:1:rel:{hash_to_hex(release.id)}"), | ||||
revision=parse_swhid(f"swh:1:rev:{hash_to_hex(revision.id)}"), | revision=parse_swhid(f"swh:1:rev:{hash_to_hex(revision.id)}"), | ||||
directory=parse_swhid(f"swh:1:dir:{hash_to_hex(directory.id)}"), | directory=parse_swhid(f"swh:1:dir:{hash_to_hex(directory.id)}"), | ||||
path=b"/foo/bar", | path=b"/foo/bar", | ||||
) | ) | ||||
origin_metadata = RawExtrinsicMetadata( | origin_metadata = RawExtrinsicMetadata( | ||||
type=MetadataTargetType.ORIGIN, | type=MetadataTargetType.ORIGIN, | ||||
Show All 31 Lines |