Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/nixguix/tests/test_nixguix.py
Show All 12 Lines | |||||
from swh.storage.interface import StorageInterface | from swh.storage.interface import StorageInterface | ||||
from typing import Dict, Optional, Tuple | from typing import Dict, Optional, Tuple | ||||
from unittest.mock import patch | from unittest.mock import patch | ||||
from swh.model.model import Snapshot, SnapshotBranch, TargetType | from swh.model.model import Snapshot, SnapshotBranch, TargetType | ||||
from swh.loader.package.archive.loader import ArchiveLoader | from swh.loader.package.archive.loader import ArchiveLoader | ||||
from swh.loader.package.nixguix.loader import ( | from swh.loader.package.nixguix.loader import ( | ||||
NixGuixPackageInfo, | |||||
NixGuixLoader, | NixGuixLoader, | ||||
retrieve_sources, | retrieve_sources, | ||||
clean_sources, | clean_sources, | ||||
) | ) | ||||
from swh.loader.package.utils import download | from swh.loader.package.utils import download | ||||
from swh.model.hashutil import hash_to_bytes, hash_to_hex | from swh.model.hashutil import hash_to_bytes, hash_to_hex | ||||
from swh.storage.exc import HashCollision | from swh.storage.exc import HashCollision | ||||
▲ Show 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | |||||
def test_resolve_revision_from(swh_config, requests_mock_datadir): | def test_resolve_revision_from(swh_config, requests_mock_datadir): | ||||
loader = NixGuixLoader(sources_url) | loader = NixGuixLoader(sources_url) | ||||
known_artifacts = { | known_artifacts = { | ||||
"id1": {"extrinsic": {"raw": {"url": "url1", "integrity": "integrity1"}}}, | "id1": {"extrinsic": {"raw": {"url": "url1", "integrity": "integrity1"}}}, | ||||
"id2": {"extrinsic": {"raw": {"url": "url2", "integrity": "integrity2"}}}, | "id2": {"extrinsic": {"raw": {"url": "url2", "integrity": "integrity2"}}}, | ||||
} | } | ||||
metadata = {"url": "url1", "integrity": "integrity1"} | p_info = NixGuixPackageInfo.from_metadata( | ||||
assert loader.resolve_revision_from(known_artifacts, metadata) == "id1" | {"url": "url1", "integrity": "integrity1"} | ||||
metadata = {"url": "url3", "integrity": "integrity3"} | ) | ||||
assert loader.resolve_revision_from(known_artifacts, metadata) == None # noqa | assert loader.resolve_revision_from(known_artifacts, p_info) == "id1" | ||||
p_info = NixGuixPackageInfo.from_metadata( | |||||
{"url": "url3", "integrity": "integrity3"} | |||||
) | |||||
assert loader.resolve_revision_from(known_artifacts, p_info) == None # noqa | |||||
def test_evaluation_branch(swh_config, requests_mock_datadir): | def test_evaluation_branch(swh_config, requests_mock_datadir): | ||||
loader = NixGuixLoader(sources_url) | loader = NixGuixLoader(sources_url) | ||||
res = loader.load() | res = loader.load() | ||||
assert res["status"] == "eventful" | assert res["status"] == "eventful" | ||||
assert_last_visit_matches( | assert_last_visit_matches( | ||||
▲ Show 20 Lines • Show All 206 Lines • Show Last 20 Lines |