Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_model.py
Show All 39 Lines | from swh.model.model import ( | ||||
Revision, | Revision, | ||||
SkippedContent, | SkippedContent, | ||||
Snapshot, | Snapshot, | ||||
Timestamp, | Timestamp, | ||||
TimestampWithTimezone, | TimestampWithTimezone, | ||||
) | ) | ||||
from swh.model.tests.test_identifiers import ( | from swh.model.tests.test_identifiers import ( | ||||
directory_example, | directory_example, | ||||
metadata_example, | |||||
release_example, | release_example, | ||||
revision_example, | revision_example, | ||||
snapshot_example, | snapshot_example, | ||||
) | ) | ||||
@given(strategies.objects()) | @given(strategies.objects()) | ||||
def test_todict_inverse_fromdict(objtype_and_obj): | def test_todict_inverse_fromdict(objtype_and_obj): | ||||
Show All 27 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,132 Lines • Show Last 20 Lines |