Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/npm/tests/test_npm.py
Show First 20 Lines • Show All 319 Lines • ▼ Show 20 Lines | def test_npm_loader_first_visit(swh_config, requests_mock_datadir): | ||||
assert ( | assert ( | ||||
list(loader.storage.revision_missing(_expected_new_revisions_first_visit)) == [] | list(loader.storage.revision_missing(_expected_new_revisions_first_visit)) == [] | ||||
) | ) | ||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": expected_snapshot_id, | "id": expected_snapshot_id, | ||||
"branches": { | "branches": { | ||||
"HEAD": {"target": "releases/0.0.4", "target_type": "alias"}, | b"HEAD": {"target": b"releases/0.0.4", "target_type": "alias"}, | ||||
"releases/0.0.2": { | b"releases/0.0.2": { | ||||
"target": "d8a1c7474d2956ac598a19f0f27d52f7015f117e", | "target": hash_to_bytes("d8a1c7474d2956ac598a19f0f27d52f7015f117e"), | ||||
"target_type": "revision", | "target_type": "revision", | ||||
}, | }, | ||||
"releases/0.0.3": { | b"releases/0.0.3": { | ||||
"target": "5f9eb78af37ffd12949f235e86fac04898f9f72a", | "target": hash_to_bytes("5f9eb78af37ffd12949f235e86fac04898f9f72a"), | ||||
"target_type": "revision", | "target_type": "revision", | ||||
}, | }, | ||||
"releases/0.0.4": { | b"releases/0.0.4": { | ||||
"target": "ba019b192bdb94bd0b5bd68b3a5f92b5acc2239a", | "target": hash_to_bytes("ba019b192bdb94bd0b5bd68b3a5f92b5acc2239a"), | ||||
"target_type": "revision", | "target_type": "revision", | ||||
}, | }, | ||||
}, | }, | ||||
} | } | ||||
check_snapshot(expected_snapshot, loader.storage) | check_snapshot(expected_snapshot, loader.storage) | ||||
def test_npm_loader_incremental_visit(swh_config, requests_mock_datadir_visits): | def test_npm_loader_incremental_visit(swh_config, requests_mock_datadir_visits): | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | assert { # 1 new releases artifacts | ||||
"revision": 2, | "revision": 2, | ||||
"skipped_content": 0, | "skipped_content": 0, | ||||
"snapshot": 1, | "snapshot": 1, | ||||
} == stats | } == stats | ||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": "b11ebac8c9d0c9e5063a2df693a18e3aba4b2f92", | "id": "b11ebac8c9d0c9e5063a2df693a18e3aba4b2f92", | ||||
"branches": { | "branches": { | ||||
"HEAD": {"target_type": "alias", "target": "releases/0.1.0"}, | b"HEAD": {"target_type": "alias", "target": b"releases/0.1.0"}, | ||||
"releases/0.1.0": { | b"releases/0.1.0": { | ||||
"target_type": "revision", | "target_type": "revision", | ||||
"target": "845673bfe8cbd31b1eaf757745a964137e6f9116", | "target": hash_to_bytes("845673bfe8cbd31b1eaf757745a964137e6f9116"), | ||||
}, | }, | ||||
"releases/0.1.1-alpha.14": { | b"releases/0.1.1-alpha.14": { | ||||
"target_type": "revision", | "target_type": "revision", | ||||
"target": "05181c12cd8c22035dd31155656826b85745da37", | "target": hash_to_bytes("05181c12cd8c22035dd31155656826b85745da37"), | ||||
}, | }, | ||||
}, | }, | ||||
} | } | ||||
check_snapshot(expected_snapshot, loader.storage) | check_snapshot(expected_snapshot, loader.storage) | ||||
def test_npm_artifact_to_revision_id_none(): | def test_npm_artifact_to_revision_id_none(): | ||||
"""Current loader version should stop soon if nothing can be found | """Current loader version should stop soon if nothing can be found | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | def test_npm_artifact_use_mtime_if_no_time(swh_config, requests_mock_datadir): | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
assert actual_load_status["status"] == "eventful" | assert actual_load_status["status"] == "eventful" | ||||
# artifact is used | # artifact is used | ||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": "d6e08e19159f77983242877c373c75222d5ae9dd", | "id": "d6e08e19159f77983242877c373c75222d5ae9dd", | ||||
"branches": { | "branches": { | ||||
"HEAD": {"target_type": "alias", "target": "releases/0.0.1"}, | b"HEAD": {"target_type": "alias", "target": b"releases/0.0.1"}, | ||||
"releases/0.0.1": { | b"releases/0.0.1": { | ||||
"target_type": "revision", | "target_type": "revision", | ||||
"target": "9e4dd2b40d1b46b70917c0949aa2195c823a648e", | "target": hash_to_bytes("9e4dd2b40d1b46b70917c0949aa2195c823a648e"), | ||||
}, | }, | ||||
}, | }, | ||||
} | } | ||||
check_snapshot(expected_snapshot, loader.storage) | check_snapshot(expected_snapshot, loader.storage) | ||||
assert_last_visit_matches(loader.storage, url, status="full", type="npm") | assert_last_visit_matches(loader.storage, url, status="full", type="npm") | ||||
Show All 13 Lines |