Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/deposit/tests/test_deposit.py
Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | def test_deposit_loading_ok(swh_storage, deposit_client, requests_mock_datadir): | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
expected_snapshot_id = "b2b327b33dc85818bd23c3ccda8b7e675a66ecbd" | expected_snapshot_id = "b2b327b33dc85818bd23c3ccda8b7e675a66ecbd" | ||||
assert actual_load_status == { | assert actual_load_status == { | ||||
"status": "eventful", | "status": "eventful", | ||||
"snapshot_id": expected_snapshot_id, | "snapshot_id": expected_snapshot_id, | ||||
} | } | ||||
assert_last_visit_matches(loader.storage, url, status="full", type="deposit") | assert_last_visit_matches( | ||||
loader.storage, | |||||
stats = get_stats(loader.storage) | url, | ||||
assert { | status="full", | ||||
"content": 303, | type="deposit", | ||||
"directory": 12, | snapshot=hash_to_bytes(expected_snapshot_id), | ||||
"origin": 1, | ) | ||||
"origin_visit": 1, | |||||
"release": 0, | |||||
"revision": 1, | |||||
"skipped_content": 0, | |||||
"snapshot": 1, | |||||
} == stats | |||||
revision_id_hex = "637318680351f5d78856d13264faebbd91efe9bb" | revision_id_hex = "637318680351f5d78856d13264faebbd91efe9bb" | ||||
revision_id = hash_to_bytes(revision_id_hex) | revision_id = hash_to_bytes(revision_id_hex) | ||||
expected_snapshot = Snapshot( | expected_snapshot = Snapshot( | ||||
id=hash_to_bytes(expected_snapshot_id), | id=hash_to_bytes(expected_snapshot_id), | ||||
branches={ | branches={ | ||||
b"HEAD": SnapshotBranch( | b"HEAD": SnapshotBranch( | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | expected_body = { | ||||
"revision_id": revision_id_hex, | "revision_id": revision_id_hex, | ||||
"directory_id": hash_to_hex(revision.directory), | "directory_id": hash_to_hex(revision.directory), | ||||
"snapshot_id": expected_snapshot_id, | "snapshot_id": expected_snapshot_id, | ||||
"origin_url": url, | "origin_url": url, | ||||
} | } | ||||
assert body == expected_body | assert body == expected_body | ||||
stats = get_stats(loader.storage) | |||||
assert { | |||||
"content": 303, | |||||
"directory": 12, | |||||
"origin": 1, | |||||
"origin_visit": 1, | |||||
"release": 0, | |||||
"revision": 1, | |||||
"skipped_content": 0, | |||||
"snapshot": 1, | |||||
} == stats | |||||
def test_deposit_loading_ok_2(swh_storage, deposit_client, requests_mock_datadir): | def test_deposit_loading_ok_2(swh_storage, deposit_client, requests_mock_datadir): | ||||
"""Field dates should be se appropriately | """Field dates should be se appropriately | ||||
""" | """ | ||||
external_id = "some-external-id" | external_id = "some-external-id" | ||||
url = f"https://hal-test.archives-ouvertes.fr/{external_id}" | url = f"https://hal-test.archives-ouvertes.fr/{external_id}" | ||||
deposit_id = 777 | deposit_id = 777 | ||||
loader = DepositLoader( | loader = DepositLoader( | ||||
swh_storage, url, deposit_id, deposit_client, default_filename="archive.zip" | swh_storage, url, deposit_id, deposit_client, default_filename="archive.zip" | ||||
) | ) | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
expected_snapshot_id = "3e68440fdd7c81d283f8f3aebb6f0c8657864192" | expected_snapshot_id = "3e68440fdd7c81d283f8f3aebb6f0c8657864192" | ||||
assert actual_load_status == { | assert actual_load_status == { | ||||
"status": "eventful", | "status": "eventful", | ||||
"snapshot_id": expected_snapshot_id, | "snapshot_id": expected_snapshot_id, | ||||
} | } | ||||
assert_last_visit_matches(loader.storage, url, status="full", type="deposit") | assert_last_visit_matches( | ||||
loader.storage, | |||||
url, | |||||
status="full", | |||||
type="deposit", | |||||
snapshot=hash_to_bytes(expected_snapshot_id), | |||||
) | |||||
revision_id = "564d18943d71be80d0d73b43a77cfb205bcde96c" | revision_id = "564d18943d71be80d0d73b43a77cfb205bcde96c" | ||||
expected_snapshot = Snapshot( | expected_snapshot = Snapshot( | ||||
id=hash_to_bytes(expected_snapshot_id), | id=hash_to_bytes(expected_snapshot_id), | ||||
branches={ | branches={ | ||||
b"HEAD": SnapshotBranch( | b"HEAD": SnapshotBranch( | ||||
target=hash_to_bytes(revision_id), target_type=TargetType.REVISION | target=hash_to_bytes(revision_id), target_type=TargetType.REVISION | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | def test_deposit_loading_ok_3(swh_storage, deposit_client, requests_mock_datadir): | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
expected_snapshot_id = "0ac7b54c042a026389f2087dc16f1d5c644ed0e4" | expected_snapshot_id = "0ac7b54c042a026389f2087dc16f1d5c644ed0e4" | ||||
assert actual_load_status == { | assert actual_load_status == { | ||||
"status": "eventful", | "status": "eventful", | ||||
"snapshot_id": expected_snapshot_id, | "snapshot_id": expected_snapshot_id, | ||||
} | } | ||||
assert_last_visit_matches(loader.storage, url, status="full", type="deposit") | assert_last_visit_matches( | ||||
loader.storage, | |||||
url, | |||||
status="full", | |||||
type="deposit", | |||||
snapshot=hash_to_bytes(expected_snapshot_id), | |||||
) |