diff --git a/requirements-swh.txt b/requirements-swh.txt --- a/requirements-swh.txt +++ b/requirements-swh.txt @@ -1,4 +1,4 @@ swh.model >= 0.4.0 swh.storage >= 0.22.0 swh.scheduler >= 0.0.39 -swh.loader.core >= 0.16.0 +swh.loader.core >= 0.17.0 diff --git a/swh/loader/mercurial/tests/test_loader.py b/swh/loader/mercurial/tests/test_loader.py --- a/swh/loader/mercurial/tests/test_loader.py +++ b/swh/loader/mercurial/tests/test_loader.py @@ -184,7 +184,7 @@ archive_name = "hello" archive_path = os.path.join(datadir, f"{archive_name}.tgz") - # Ensure archive loader yields the same snapshot + loader = HgArchiveBundle20Loader( url=archive_path, visit_date="2016-05-03 15:16:32+00", ) @@ -205,7 +205,29 @@ } # That visit yields the same snapshot assert_last_visit_matches( - loader.storage, archive_path, status="partial", type="hg", snapshot=None + loader.storage, archive_path, status="failed", type="hg", snapshot=None + ) + + +def test_visit_error_with_snapshot_partial(swh_config, datadir, tmp_path, mocker): + """Incomplete ingestion leads to a 'partial' ingestion status""" + mock = mocker.patch("swh.loader.mercurial.loader.HgBundle20Loader.store_metadata") + mock.side_effect = ValueError + + archive_name = "the-sandbox" + archive_path = os.path.join(datadir, f"{archive_name}.tgz") + repo_url = prepare_repository_from_archive(archive_path, archive_name, tmp_path) + + loader = HgBundle20Loader(repo_url) + + assert loader.load() == {"status": "failed"} + + assert_last_visit_matches( + loader.storage, + repo_url, + status="partial", + type="hg", + snapshot=hash_to_bytes("3b8fe58e467deb7597b12a5fd3b2c096b8c02028"), )