Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_identifiers.py
Show First 20 Lines • Show All 760 Lines • ▼ Show 20 Lines | class SnapshotIdentifier(unittest.TestCase): | ||||
def test_all_types(self): | def test_all_types(self): | ||||
self.assertEqual( | self.assertEqual( | ||||
identifiers.snapshot_identifier(remove_id(self.all_types)), | identifiers.snapshot_identifier(remove_id(self.all_types)), | ||||
identifiers.identifier_to_str(self.all_types["id"]), | identifiers.identifier_to_str(self.all_types["id"]), | ||||
) | ) | ||||
class RawExtrinsicMetadataIdentifier(unittest.TestCase): | authority_example = { | ||||
def setUp(self): | |||||
super().setUp() | |||||
self.authority = { | |||||
"type": "forge", | "type": "forge", | ||||
"url": "https://forge.softwareheritage.org/", | "url": "https://forge.softwareheritage.org/", | ||||
} | } | ||||
self.fetcher = { | fetcher_example = { | ||||
"name": "swh-phabricator-metadata-fetcher", | "name": "swh-phabricator-metadata-fetcher", | ||||
"version": "0.0.1", | "version": "0.0.1", | ||||
} | } | ||||
metadata_example = { | |||||
self.minimal = { | |||||
"type": "content", | "type": "content", | ||||
"target": parse_swhid("swh:1:cnt:568aaf43d83b2c3df8067f3bedbb97d83260be6d"), | "target": "swh:1:cnt:568aaf43d83b2c3df8067f3bedbb97d83260be6d", | ||||
"discovery_date": datetime.datetime( | "discovery_date": datetime.datetime( | ||||
2021, 1, 25, 11, 27, 51, tzinfo=datetime.timezone.utc | 2021, 1, 25, 11, 27, 51, tzinfo=datetime.timezone.utc | ||||
), | ), | ||||
"authority": self.authority, | "authority": authority_example, | ||||
"fetcher": self.fetcher, | "fetcher": fetcher_example, | ||||
"format": "json", | "format": "json", | ||||
"metadata": b'{"foo": "bar"}', | "metadata": b'{"foo": "bar"}', | ||||
} | } | ||||
class RawExtrinsicMetadataIdentifier(unittest.TestCase): | |||||
def setUp(self): | |||||
super().setUp() | |||||
self.minimal = metadata_example | |||||
self.maximal = { | self.maximal = { | ||||
**self.minimal, | **self.minimal, | ||||
"origin": "https://forge.softwareheritage.org/source/swh-model/", | "origin": "https://forge.softwareheritage.org/source/swh-model/", | ||||
"visit": 42, | "visit": 42, | ||||
"snapshot": parse_swhid("swh:1:snp:" + "00" * 20), | "snapshot": parse_swhid("swh:1:snp:" + "00" * 20), | ||||
"release": parse_swhid("swh:1:rel:" + "01" * 20), | "release": parse_swhid("swh:1:rel:" + "01" * 20), | ||||
"revision": parse_swhid("swh:1:rev:" + "02" * 20), | "revision": parse_swhid("swh:1:rev:" + "02" * 20), | ||||
"path": b"/abc/def", | "path": b"/abc/def", | ||||
▲ Show 20 Lines • Show All 647 Lines • Show Last 20 Lines |