Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/pypi/tests/test_pypi.py
Show First 20 Lines • Show All 375 Lines • ▼ Show 20 Lines | expected_branches = { | ||||
b"releases/1.2.0": { | b"releases/1.2.0": { | ||||
"target": hash_to_bytes("e445da4da22b31bfebb6ffc4383dbf839a074d21"), | "target": hash_to_bytes("e445da4da22b31bfebb6ffc4383dbf839a074d21"), | ||||
"target_type": "revision", | "target_type": "revision", | ||||
}, | }, | ||||
b"HEAD": {"target": b"releases/1.2.0", "target_type": "alias",}, | b"HEAD": {"target": b"releases/1.2.0", "target_type": "alias",}, | ||||
} | } | ||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": expected_snapshot_id, | "id": hash_to_bytes(expected_snapshot_id), | ||||
"branches": expected_branches, | "branches": expected_branches, | ||||
} | } | ||||
check_snapshot(expected_snapshot, storage=loader.storage) | check_snapshot(expected_snapshot, storage=loader.storage) | ||||
assert_last_visit_matches(loader.storage, url, status="partial", type="pypi") | assert_last_visit_matches(loader.storage, url, status="partial", type="pypi") | ||||
def test_visit_with_1_release_artifact(swh_config, requests_mock_datadir): | def test_visit_with_1_release_artifact(swh_config, requests_mock_datadir): | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | expected_branches = { | ||||
b"releases/1.2.0": { | b"releases/1.2.0": { | ||||
"target": hash_to_bytes("e445da4da22b31bfebb6ffc4383dbf839a074d21"), | "target": hash_to_bytes("e445da4da22b31bfebb6ffc4383dbf839a074d21"), | ||||
"target_type": "revision", | "target_type": "revision", | ||||
}, | }, | ||||
b"HEAD": {"target": b"releases/1.2.0", "target_type": "alias",}, | b"HEAD": {"target": b"releases/1.2.0", "target_type": "alias",}, | ||||
} | } | ||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": expected_snapshot_id, | "id": hash_to_bytes(expected_snapshot_id), | ||||
"branches": expected_branches, | "branches": expected_branches, | ||||
} | } | ||||
check_snapshot(expected_snapshot, loader.storage) | check_snapshot(expected_snapshot, loader.storage) | ||||
assert_last_visit_matches(loader.storage, url, status="full", type="pypi") | assert_last_visit_matches(loader.storage, url, status="full", type="pypi") | ||||
def test_multiple_visits_with_no_change(swh_config, requests_mock_datadir): | def test_multiple_visits_with_no_change(swh_config, requests_mock_datadir): | ||||
Show All 33 Lines | expected_branches = { | ||||
b"releases/1.2.0": { | b"releases/1.2.0": { | ||||
"target": hash_to_bytes("e445da4da22b31bfebb6ffc4383dbf839a074d21"), | "target": hash_to_bytes("e445da4da22b31bfebb6ffc4383dbf839a074d21"), | ||||
"target_type": "revision", | "target_type": "revision", | ||||
}, | }, | ||||
b"HEAD": {"target": b"releases/1.2.0", "target_type": "alias",}, | b"HEAD": {"target": b"releases/1.2.0", "target_type": "alias",}, | ||||
} | } | ||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": snapshot_id, | "id": hash_to_bytes(snapshot_id), | ||||
"branches": expected_branches, | "branches": expected_branches, | ||||
} | } | ||||
check_snapshot(expected_snapshot, loader.storage) | check_snapshot(expected_snapshot, loader.storage) | ||||
actual_load_status2 = loader.load() | actual_load_status2 = loader.load() | ||||
assert actual_load_status2 == { | assert actual_load_status2 == { | ||||
"status": "uneventful", | "status": "uneventful", | ||||
"snapshot_id": actual_load_status2["snapshot_id"], | "snapshot_id": actual_load_status2["snapshot_id"], | ||||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | expected_branches = { | ||||
}, | }, | ||||
b"releases/1.3.0": { | b"releases/1.3.0": { | ||||
"target": hash_to_bytes("51247143b01445c9348afa9edfae31bf7c5d86b1"), | "target": hash_to_bytes("51247143b01445c9348afa9edfae31bf7c5d86b1"), | ||||
"target_type": "revision", | "target_type": "revision", | ||||
}, | }, | ||||
b"HEAD": {"target": b"releases/1.3.0", "target_type": "alias",}, | b"HEAD": {"target": b"releases/1.3.0", "target_type": "alias",}, | ||||
} | } | ||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": expected_snapshot_id2, | "id": hash_to_bytes(expected_snapshot_id2), | ||||
"branches": expected_branches, | "branches": expected_branches, | ||||
} | } | ||||
check_snapshot(expected_snapshot, loader.storage) | check_snapshot(expected_snapshot, loader.storage) | ||||
assert_last_visit_matches(loader.storage, url, status="full", type="pypi") | assert_last_visit_matches(loader.storage, url, status="full", type="pypi") | ||||
urls = [ | urls = [ | ||||
Show All 37 Lines | expected_branches = { | ||||
}, | }, | ||||
b"releases/1.1.0/nexter-1.1.0.tar.gz": { | b"releases/1.1.0/nexter-1.1.0.tar.gz": { | ||||
"target": hash_to_bytes("0bf88f5760cca7665d0af4d6575d9301134fe11a"), | "target": hash_to_bytes("0bf88f5760cca7665d0af4d6575d9301134fe11a"), | ||||
"target_type": "revision", | "target_type": "revision", | ||||
}, | }, | ||||
} | } | ||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": expected_snapshot_id, | "id": hash_to_bytes(expected_snapshot_id), | ||||
"branches": expected_branches, | "branches": expected_branches, | ||||
} | } | ||||
check_snapshot(expected_snapshot, loader.storage) | check_snapshot(expected_snapshot, loader.storage) | ||||
assert_last_visit_matches(loader.storage, url, status="full", type="pypi") | assert_last_visit_matches(loader.storage, url, status="full", type="pypi") | ||||
def test_pypi_artifact_to_revision_id_none(): | def test_pypi_artifact_to_revision_id_none(): | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | def test_pypi_artifact_with_no_intrinsic_metadata(swh_config, requests_mock_datadir): | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
expected_snapshot_id = "1a8893e6a86f444e8be8e7bda6cb34fb1735a00e" | expected_snapshot_id = "1a8893e6a86f444e8be8e7bda6cb34fb1735a00e" | ||||
assert actual_load_status == { | assert actual_load_status == { | ||||
"status": "eventful", | "status": "eventful", | ||||
"snapshot_id": expected_snapshot_id, | "snapshot_id": expected_snapshot_id, | ||||
} | } | ||||
# no branch as one artifact without any intrinsic metadata | # no branch as one artifact without any intrinsic metadata | ||||
expected_snapshot = {"id": expected_snapshot_id, "branches": {}} | expected_snapshot = {"id": hash_to_bytes(expected_snapshot_id), "branches": {}} | ||||
check_snapshot(expected_snapshot, loader.storage) | check_snapshot(expected_snapshot, loader.storage) | ||||
assert_last_visit_matches(loader.storage, url, status="full", type="pypi") | assert_last_visit_matches(loader.storage, url, status="full", type="pypi") |