Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/tests/test_origin_revision_layer.py
Show All 10 Lines | |||||
from swh.model.hashutil import hash_to_bytes | from swh.model.hashutil import hash_to_bytes | ||||
from swh.model.model import Sha1Git | from swh.model.model import Sha1Git | ||||
from swh.provenance.archive import ArchiveInterface | from swh.provenance.archive import ArchiveInterface | ||||
from swh.provenance.interface import EntityType, ProvenanceInterface, RelationType | from swh.provenance.interface import EntityType, ProvenanceInterface, RelationType | ||||
from swh.provenance.model import OriginEntry | from swh.provenance.model import OriginEntry | ||||
from swh.provenance.origin import origin_add | from swh.provenance.origin import origin_add | ||||
from swh.provenance.tests.conftest import fill_storage, get_datafile, load_repo_data | from swh.provenance.tests.conftest import fill_storage, get_datafile, load_repo_data | ||||
from swh.storage.postgresql.storage import Storage | |||||
class SynthRelation(TypedDict): | class SynthRelation(TypedDict): | ||||
src: Sha1Git | src: Sha1Git | ||||
dst: Sha1Git | dst: Sha1Git | ||||
name: str | name: str | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | |||||
@pytest.mark.parametrize( | @pytest.mark.parametrize( | ||||
"repo, visit", | "repo, visit", | ||||
(("with-merges", "visits-01"),), | (("with-merges", "visits-01"),), | ||||
) | ) | ||||
def test_origin_revision_layer( | def test_origin_revision_layer( | ||||
provenance: ProvenanceInterface, | provenance: ProvenanceInterface, | ||||
swh_storage: Storage, | |||||
archive: ArchiveInterface, | archive: ArchiveInterface, | ||||
repo: str, | repo: str, | ||||
visit: str, | visit: str, | ||||
) -> None: | ) -> None: | ||||
# read data/README.md for more details on how these datasets are generated | # read data/README.md for more details on how these datasets are generated | ||||
data = load_repo_data(repo) | data = load_repo_data(repo) | ||||
fill_storage(swh_storage, data) | fill_storage(archive.storage, data) | ||||
syntheticfile = get_datafile(f"origin-revision_{repo}_{visit}.txt") | syntheticfile = get_datafile(f"origin-revision_{repo}_{visit}.txt") | ||||
origins = [ | origins = [ | ||||
{"url": status["origin"], "snap": status["snapshot"]} | {"url": status["origin"], "snap": status["snapshot"]} | ||||
for status in data["origin_visit_status"] | for status in data["origin_visit_status"] | ||||
if status["snapshot"] is not None | if status["snapshot"] is not None | ||||
] | ] | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |