diff --git a/swh/loader/package/loader.py b/swh/loader/package/loader.py --- a/swh/loader/package/loader.py +++ b/swh/loader/package/loader.py @@ -340,7 +340,7 @@ """ status_load = "uneventful" # either: eventful, uneventful, failed - status_visit = "full" # either: partial, full + status_visit = "full" # either: partial, full, not_found, failed tmp_revisions = {} # type: Dict[str, List] snapshot = None failed_branches: List[str] = [] @@ -407,7 +407,7 @@ except Exception as e: logger.exception("Failed to get previous state for %s", self.url) sentry_sdk.capture_exception(e) - status_visit = "partial" + status_visit = "failed" status_load = "failed" return finalize_visit() @@ -452,7 +452,7 @@ if not tmp_revisions: # We could not load any revisions; fail completely - status_visit = "partial" + status_visit = "failed" status_load = "failed" return finalize_visit() @@ -471,7 +471,7 @@ except Exception as e: logger.exception("Failed to build snapshot for origin %s", self.url) sentry_sdk.capture_exception(e) - status_visit = "partial" + status_visit = "failed" status_load = "failed" if snapshot: diff --git a/swh/loader/package/npm/tests/test_npm.py b/swh/loader/package/npm/tests/test_npm.py --- a/swh/loader/package/npm/tests/test_npm.py +++ b/swh/loader/package/npm/tests/test_npm.py @@ -700,4 +700,4 @@ "status": "failed", } - assert_last_visit_matches(loader.storage, url, status="partial", type="npm") + assert_last_visit_matches(loader.storage, url, status="failed", type="npm") diff --git a/swh/loader/package/pypi/tests/test_pypi.py b/swh/loader/package/pypi/tests/test_pypi.py --- a/swh/loader/package/pypi/tests/test_pypi.py +++ b/swh/loader/package/pypi/tests/test_pypi.py @@ -251,6 +251,36 @@ assert_last_visit_matches(loader.storage, url, status="partial", type="pypi") +def test_pypi_fail__load_snapshot(swh_config, requests_mock_datadir): + """problem during loading: {visit: failed, status: failed, no snapshot} + + """ + url = "https://pypi.org/project/0805nexter" + with patch( + "swh.loader.package.pypi.loader.PyPILoader._load_snapshot", + side_effect=ValueError("Fake problem to fail visit"), + ): + loader = PyPILoader(url) + + actual_load_status = loader.load() + assert actual_load_status == {"status": "failed"} + + stats = get_stats(loader.storage) + + assert { + "content": 6, + "directory": 4, + "origin": 1, + "origin_visit": 1, + "release": 0, + "revision": 2, + "skipped_content": 0, + "snapshot": 0, + } == stats + + assert_last_visit_matches(loader.storage, url, status="failed", type="pypi") + + # problem during loading: # {visit: partial, status: uneventful, no snapshot} @@ -279,7 +309,7 @@ "snapshot": 0, } == stats - assert_last_visit_matches(loader.storage, url, status="partial", type="pypi") + assert_last_visit_matches(loader.storage, url, status="failed", type="pypi") # problem during loading: failure early enough in between swh contents...