Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/storage_data.py
# Copyright (C) 2015-2019 The Software Heritage developers | # Copyright (C) 2015-2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import datetime | import datetime | ||||
from swh.model.hashutil import hash_to_bytes | from swh.model.hashutil import hash_to_bytes, hash_to_hex | ||||
from swh.model import from_disk | from swh.model import from_disk | ||||
class StorageData: | class StorageData: | ||||
def __getattr__(self, key): | def __getattr__(self, key): | ||||
try: | try: | ||||
v = globals()[key] | v = globals()[key] | ||||
except KeyError as e: | except KeyError as e: | ||||
▲ Show 20 Lines • Show All 451 Lines • ▼ Show 20 Lines | "branches": { | ||||
"target_type": "snapshot", | "target_type": "snapshot", | ||||
}, | }, | ||||
b"dangling": None, | b"dangling": None, | ||||
}, | }, | ||||
} | } | ||||
snapshots = (snapshot, empty_snapshot, complete_snapshot) | snapshots = (snapshot, empty_snapshot, complete_snapshot) | ||||
content_metadata = { | |||||
"id": f"swh:1:cnt:{cont['sha1_git']}", | |||||
"context": {"origin": origin["url"]}, | |||||
"discovery_date": datetime.datetime( | |||||
2015, 1, 1, 21, 0, 0, tzinfo=datetime.timezone.utc | |||||
), | |||||
"authority": { | |||||
"type": metadata_authority["type"], | |||||
"url": metadata_authority["url"], | |||||
}, | |||||
"fetcher": { | |||||
"name": metadata_fetcher["name"], | |||||
"version": metadata_fetcher["version"], | |||||
}, | |||||
"format": "json", | |||||
"metadata": b'{"foo": "bar"}', | |||||
} | |||||
content_metadata2 = { | |||||
"id": f"swh:1:cnt:{cont['sha1_git']}", | |||||
"context": {"origin": origin2["url"]}, | |||||
"discovery_date": datetime.datetime( | |||||
2017, 1, 1, 22, 0, 0, tzinfo=datetime.timezone.utc | |||||
), | |||||
"authority": { | |||||
"type": metadata_authority["type"], | |||||
"url": metadata_authority["url"], | |||||
}, | |||||
"fetcher": { | |||||
"name": metadata_fetcher["name"], | |||||
"version": metadata_fetcher["version"], | |||||
}, | |||||
"format": "yaml", | |||||
"metadata": b"foo: bar", | |||||
} | |||||
content_metadata3 = { | |||||
"id": f"swh:1:cnt:{cont['sha1_git']}", | |||||
"context": { | |||||
"origin": origin["url"], | |||||
"visit": 42, | |||||
"snapshot": f"swh:1:snp:{hash_to_hex(snapshot['id'])}", | |||||
"release": f"swh:1:rel:{hash_to_hex(release['id'])}", | |||||
"revision": f"swh:1:rev:{hash_to_hex(revision['id'])}", | |||||
"directory": f"swh:1:dir:{hash_to_hex(dir['id'])}", | |||||
"path": b"/foo/bar", | |||||
}, | |||||
"discovery_date": datetime.datetime( | |||||
2017, 1, 1, 22, 0, 0, tzinfo=datetime.timezone.utc | |||||
), | |||||
"authority": { | |||||
"type": metadata_authority2["type"], | |||||
"url": metadata_authority2["url"], | |||||
}, | |||||
"fetcher": { | |||||
"name": metadata_fetcher2["name"], | |||||
"version": metadata_fetcher2["version"], | |||||
}, | |||||
"format": "yaml", | |||||
"metadata": b"foo: bar", | |||||
} | |||||
origin_metadata = { | origin_metadata = { | ||||
"origin_url": origin["url"], | "origin_url": 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 | ||||
), | ), | ||||
"authority": { | "authority": { | ||||
"type": metadata_authority["type"], | "type": metadata_authority["type"], | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |