Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/mercurial/tests/test_loader.py
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | assert stats == { | ||||
"revision": 58, | "revision": 58, | ||||
"skipped_content": 0, | "skipped_content": 0, | ||||
"snapshot": 1, | "snapshot": 1, | ||||
} | } | ||||
tip_revision_develop = "a9c4534552df370f43f0ef97146f393ef2f2a08c" | tip_revision_develop = "a9c4534552df370f43f0ef97146f393ef2f2a08c" | ||||
tip_revision_default = "70e750bb046101fdced06f428e73fee471509c56" | tip_revision_default = "70e750bb046101fdced06f428e73fee471509c56" | ||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": "3b8fe58e467deb7597b12a5fd3b2c096b8c02028", | "id": hash_to_bytes("3b8fe58e467deb7597b12a5fd3b2c096b8c02028"), | ||||
"branches": { | "branches": { | ||||
b"develop": { | b"develop": { | ||||
"target": hash_to_bytes(tip_revision_develop), | "target": hash_to_bytes(tip_revision_develop), | ||||
"target_type": "revision", | "target_type": "revision", | ||||
}, | }, | ||||
b"default": { | b"default": { | ||||
"target": hash_to_bytes(tip_revision_default), | "target": hash_to_bytes(tip_revision_default), | ||||
"target_type": "revision", | "target_type": "revision", | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | def test_loader_hg_new_visit_with_release(swh_config, datadir, tmp_path): | ||||
# cf. test_loader.org for explaining from where those hashes | # cf. test_loader.org for explaining from where those hashes | ||||
tip_release = "515c4d72e089404356d0f4b39d60f948b8999140" | tip_release = "515c4d72e089404356d0f4b39d60f948b8999140" | ||||
release = loader.storage.release_get([hash_to_bytes(tip_release)]) | release = loader.storage.release_get([hash_to_bytes(tip_release)]) | ||||
assert release is not None | assert release is not None | ||||
tip_revision_default = "c3dbe4fbeaaa98dd961834e4007edb3efb0e2a27" | tip_revision_default = "c3dbe4fbeaaa98dd961834e4007edb3efb0e2a27" | ||||
revision = loader.storage.revision_get([hash_to_bytes(tip_revision_default)]) | revision = loader.storage.revision_get([hash_to_bytes(tip_revision_default)]) | ||||
assert revision is not None | assert revision is not None | ||||
expected_snapshot_id = "d35668e02e2ba4321dc951cd308cf883786f918a" | |||||
expected_snapshot = { | expected_snapshot = { | ||||
ardumontUnsubmitted Not Done Inline Actionsardumont: ```
expected_snapshot_id = hash_to_bytes("d35668e02e2ba4321dc951cd308cf883786f918a")
``` | |||||
"id": expected_snapshot_id, | "id": hash_to_bytes("d35668e02e2ba4321dc951cd308cf883786f918a"), | ||||
Not Done Inline Actions"id": expected_snapshot_id, ardumont: ```
"id": expected_snapshot_id,
``` | |||||
"branches": { | "branches": { | ||||
b"default": { | b"default": { | ||||
"target": hash_to_bytes(tip_revision_default), | "target": hash_to_bytes(tip_revision_default), | ||||
"target_type": "revision", | "target_type": "revision", | ||||
}, | }, | ||||
b"0.1": {"target": hash_to_bytes(tip_release), "target_type": "release",}, | b"0.1": {"target": hash_to_bytes(tip_release), "target_type": "release",}, | ||||
b"HEAD": {"target": b"default", "target_type": "alias",}, | b"HEAD": {"target": b"default", "target_type": "alias",}, | ||||
}, | }, | ||||
Show All 21 Lines | def test_loader_hg_new_visit_with_release(swh_config, datadir, tmp_path): | ||||
assert stats2 == expected_stats | assert stats2 == expected_stats | ||||
# That visit yields the same snapshot | # That visit yields the same snapshot | ||||
assert_last_visit_matches( | assert_last_visit_matches( | ||||
loader2.storage, | loader2.storage, | ||||
archive_path, | archive_path, | ||||
status="full", | status="full", | ||||
type="hg", | type="hg", | ||||
snapshot=hash_to_bytes(expected_snapshot_id), | snapshot=expected_snapshot["id"], | ||||
Not Done Inline Actionssnapshot=expected_snapshot_id, ardumont: ```
snapshot=expected_snapshot_id,
``` | |||||
) | ) | ||||
def test_visit_with_archive_decompression_failure(swh_config, mocker, datadir): | def test_visit_with_archive_decompression_failure(swh_config, mocker, datadir): | ||||
"""Failure to decompress should fail early, no data is ingested""" | """Failure to decompress should fail early, no data is ingested""" | ||||
mock_patoo = mocker.patch("swh.loader.mercurial.archive_extract.patoolib") | mock_patoo = mocker.patch("swh.loader.mercurial.archive_extract.patoolib") | ||||
mock_patoo.side_effect = ValueError | mock_patoo.side_effect = ValueError | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |