Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/npm/tests/test_npm.py
Show First 20 Lines • Show All 317 Lines • ▼ Show 20 Lines | assert ( | ||||
== [] | == [] | ||||
) | ) | ||||
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": hash_to_bytes(expected_snapshot_id), | ||||
"branches": { | "branches": { | ||||
b"HEAD": {"target": b"releases/0.0.4", "target_type": "alias"}, | b"HEAD": {"target": b"releases/0.0.4", "target_type": "alias"}, | ||||
b"releases/0.0.2": { | b"releases/0.0.2": { | ||||
"target": hash_to_bytes("d8a1c7474d2956ac598a19f0f27d52f7015f117e"), | "target": hash_to_bytes("d8a1c7474d2956ac598a19f0f27d52f7015f117e"), | ||||
"target_type": "revision", | "target_type": "revision", | ||||
}, | }, | ||||
b"releases/0.0.3": { | b"releases/0.0.3": { | ||||
"target": hash_to_bytes("5f9eb78af37ffd12949f235e86fac04898f9f72a"), | "target": hash_to_bytes("5f9eb78af37ffd12949f235e86fac04898f9f72a"), | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | assert { # 1 new releases artifacts | ||||
"person": 1, | "person": 1, | ||||
"release": 0, | "release": 0, | ||||
"revision": 2, | "revision": 2, | ||||
"skipped_content": 0, | "skipped_content": 0, | ||||
"snapshot": 1, | "snapshot": 1, | ||||
} == stats | } == stats | ||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": "b11ebac8c9d0c9e5063a2df693a18e3aba4b2f92", | "id": hash_to_bytes("b11ebac8c9d0c9e5063a2df693a18e3aba4b2f92"), | ||||
"branches": { | "branches": { | ||||
b"HEAD": {"target_type": "alias", "target": b"releases/0.1.0"}, | b"HEAD": {"target_type": "alias", "target": b"releases/0.1.0"}, | ||||
b"releases/0.1.0": { | b"releases/0.1.0": { | ||||
"target_type": "revision", | "target_type": "revision", | ||||
"target": hash_to_bytes("845673bfe8cbd31b1eaf757745a964137e6f9116"), | "target": hash_to_bytes("845673bfe8cbd31b1eaf757745a964137e6f9116"), | ||||
}, | }, | ||||
b"releases/0.1.1-alpha.14": { | b"releases/0.1.1-alpha.14": { | ||||
"target_type": "revision", | "target_type": "revision", | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | def test_npm_artifact_with_no_intrinsic_metadata(swh_config, requests_mock_datadir): | ||||
url = package_url(package) | url = package_url(package) | ||||
loader = NpmLoader(url) | loader = NpmLoader(url) | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
assert actual_load_status["status"] == "eventful" | assert actual_load_status["status"] == "eventful" | ||||
# no branch as one artifact without any intrinsic metadata | # no branch as one artifact without any intrinsic metadata | ||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": "1a8893e6a86f444e8be8e7bda6cb34fb1735a00e", | "id": hash_to_bytes("1a8893e6a86f444e8be8e7bda6cb34fb1735a00e"), | ||||
"branches": {}, | "branches": {}, | ||||
} | } | ||||
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") | ||||
def test_npm_artifact_with_no_upload_time(swh_config, requests_mock_datadir): | def test_npm_artifact_with_no_upload_time(swh_config, requests_mock_datadir): | ||||
"""With no time upload, artifact is skipped | """With no time upload, artifact is skipped | ||||
""" | """ | ||||
package = "jammit-no-time" | package = "jammit-no-time" | ||||
url = package_url(package) | url = package_url(package) | ||||
loader = NpmLoader(url) | loader = NpmLoader(url) | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
assert actual_load_status["status"] == "uneventful" | assert actual_load_status["status"] == "uneventful" | ||||
# no branch as one artifact without any intrinsic metadata | # no branch as one artifact without any intrinsic metadata | ||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": "1a8893e6a86f444e8be8e7bda6cb34fb1735a00e", | "id": hash_to_bytes("1a8893e6a86f444e8be8e7bda6cb34fb1735a00e"), | ||||
"branches": {}, | "branches": {}, | ||||
} | } | ||||
check_snapshot(expected_snapshot, loader.storage) | check_snapshot(expected_snapshot, loader.storage) | ||||
assert_last_visit_matches(loader.storage, url, status="partial", type="npm") | assert_last_visit_matches(loader.storage, url, status="partial", type="npm") | ||||
def test_npm_artifact_use_mtime_if_no_time(swh_config, requests_mock_datadir): | def test_npm_artifact_use_mtime_if_no_time(swh_config, requests_mock_datadir): | ||||
"""With no time upload, artifact is skipped | """With no time upload, artifact is skipped | ||||
""" | """ | ||||
package = "jammit-express" | package = "jammit-express" | ||||
url = package_url(package) | url = package_url(package) | ||||
loader = NpmLoader(url) | loader = NpmLoader(url) | ||||
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": hash_to_bytes("d6e08e19159f77983242877c373c75222d5ae9dd"), | ||||
"branches": { | "branches": { | ||||
b"HEAD": {"target_type": "alias", "target": b"releases/0.0.1"}, | b"HEAD": {"target_type": "alias", "target": b"releases/0.0.1"}, | ||||
b"releases/0.0.1": { | b"releases/0.0.1": { | ||||
"target_type": "revision", | "target_type": "revision", | ||||
"target": hash_to_bytes("9e4dd2b40d1b46b70917c0949aa2195c823a648e"), | "target": hash_to_bytes("9e4dd2b40d1b46b70917c0949aa2195c823a648e"), | ||||
}, | }, | ||||
}, | }, | ||||
} | } | ||||
Show All 18 Lines |