Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_model.py
Show First 20 Lines • Show All 821 Lines • ▼ Show 20 Lines | def test_metadata_to_dict(): | ||||
} | } | ||||
m = RawExtrinsicMetadata( | m = RawExtrinsicMetadata( | ||||
type=MetadataTargetType.ORIGIN, target=_origin_url, **_common_metadata_fields, | type=MetadataTargetType.ORIGIN, target=_origin_url, **_common_metadata_fields, | ||||
) | ) | ||||
assert m.to_dict() == { | assert m.to_dict() == { | ||||
"type": "origin", | "type": "origin", | ||||
"target": _origin_url, | "target": _origin_url, | ||||
"id": b"\x9b[\x94\xf7\xa7$Dwbc\xf4\xdf\xaf(7G0t-\xd8", | "id": b"\xdc\xf4\x89\xaf\xbf\xd9[1\x08\xcb\xf3?\xea\n\x1d7_os\x08", | ||||
**common_fields, | **common_fields, | ||||
} | } | ||||
assert RawExtrinsicMetadata.from_dict(m.to_dict()) == m | assert RawExtrinsicMetadata.from_dict(m.to_dict()) == m | ||||
m = RawExtrinsicMetadata( | m = RawExtrinsicMetadata( | ||||
type=MetadataTargetType.CONTENT, | type=MetadataTargetType.CONTENT, | ||||
target=_content_swhid, | target=_content_swhid, | ||||
**_common_metadata_fields, | **_common_metadata_fields, | ||||
) | ) | ||||
assert m.to_dict() == { | assert m.to_dict() == { | ||||
"type": "content", | "type": "content", | ||||
"target": "swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2", | "target": "swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2", | ||||
"id": b"\x00\xfd\xe4\x88\xfa\xb5\xac\x7f\x16'\x96\xa8\x10\x9a\xafI\xe9>w\xa7", | "id": b"B8~?\xa1h{\x88D\xbd\xc2C\x10\x89\x0c\x95R7\xb6\x03", | ||||
**common_fields, | **common_fields, | ||||
} | } | ||||
assert RawExtrinsicMetadata.from_dict(m.to_dict()) == m | assert RawExtrinsicMetadata.from_dict(m.to_dict()) == m | ||||
def test_metadata_invalid_target(): | def test_metadata_invalid_target(): | ||||
"""Checks various invalid values for the 'target' field.""" | """Checks various invalid values for the 'target' field.""" | ||||
▲ Show 20 Lines • Show All 379 Lines • Show Last 20 Lines |