Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/npm/tests/test_npm.py
# Copyright (C) 2019 The Software Heritage developers | # Copyright (C) 2019-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import json | import json | ||||
import os | import os | ||||
import pytest | import pytest | ||||
▲ Show 20 Lines • Show All 574 Lines • ▼ Show 20 Lines | expected_snapshot = { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
check_snapshot(expected_snapshot, loader.storage) | check_snapshot(expected_snapshot, loader.storage) | ||||
origin_visit = list(loader.storage.origin_visit_get(url))[-1] | origin_visit = list(loader.storage.origin_visit_get(url))[-1] | ||||
assert origin_visit['status'] == 'full' | assert origin_visit['status'] == 'full' | ||||
assert origin_visit['type'] == 'npm' | assert origin_visit['type'] == 'npm' | ||||
def test_npm_no_artifact(swh_config, requests_mock_datadir): | |||||
"""If no artifacts at all is found for origin, the visit fails completely | |||||
""" | |||||
package = 'catify' | |||||
url = package_url(package) | |||||
loader = NpmLoader(url) | |||||
actual_load_status = loader.load() | |||||
assert actual_load_status == { | |||||
'status': 'failed', | |||||
} | |||||
origin_visit = loader.storage.origin_visit_get_latest(url) | |||||
assert origin_visit['status'] == 'partial' | |||||
assert origin_visit['type'] == 'npm' |