Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_model.py
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | from swh.model.model import ( | ||||
SkippedContent, | SkippedContent, | ||||
Snapshot, | Snapshot, | ||||
Timestamp, | Timestamp, | ||||
TimestampWithTimezone, | TimestampWithTimezone, | ||||
) | ) | ||||
from swh.model.tests.test_identifiers import ( | from swh.model.tests.test_identifiers import ( | ||||
content_example, | content_example, | ||||
directory_example, | directory_example, | ||||
metadata_example, | |||||
origin_example, | origin_example, | ||||
release_example, | release_example, | ||||
revision_example, | revision_example, | ||||
snapshot_example, | snapshot_example, | ||||
) | ) | ||||
EXAMPLE_HASH = hash_to_bytes("94a9ed024d3859793618152ea559a168bbcbb5e2") | EXAMPLE_HASH = hash_to_bytes("94a9ed024d3859793618152ea559a168bbcbb5e2") | ||||
Show All 30 Lines | def test_unique_key(): | ||||
assert OriginVisitStatus( | assert OriginVisitStatus( | ||||
origin=url, visit=42, date=date, status="created", snapshot=None | origin=url, visit=42, date=date, status="created", snapshot=None | ||||
).unique_key() == {"origin": url, "visit": "42", "date": str(date),} | ).unique_key() == {"origin": url, "visit": "42", "date": str(date),} | ||||
assert Snapshot.from_dict({**snapshot_example, "id": id_}).unique_key() == id_ | assert Snapshot.from_dict({**snapshot_example, "id": id_}).unique_key() == id_ | ||||
assert Release.from_dict({**release_example, "id": id_}).unique_key() == id_ | assert Release.from_dict({**release_example, "id": id_}).unique_key() == id_ | ||||
assert Revision.from_dict({**revision_example, "id": id_}).unique_key() == id_ | assert Revision.from_dict({**revision_example, "id": id_}).unique_key() == id_ | ||||
assert Directory.from_dict({**directory_example, "id": id_}).unique_key() == id_ | assert Directory.from_dict({**directory_example, "id": id_}).unique_key() == id_ | ||||
assert ( | |||||
RawExtrinsicMetadata.from_dict({**metadata_example, "id": id_}).unique_key() | |||||
== id_ | |||||
) | |||||
cont = Content.from_data(b"foo") | cont = Content.from_data(b"foo") | ||||
assert cont.unique_key().hex() == "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" | assert cont.unique_key().hex() == "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" | ||||
kwargs = { | kwargs = { | ||||
**cont.to_dict(), | **cont.to_dict(), | ||||
"reason": "foo", | "reason": "foo", | ||||
"status": "absent", | "status": "absent", | ||||
▲ Show 20 Lines • Show All 1,012 Lines • Show Last 20 Lines |