Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/mercurial/tests/test_loader.py
Show First 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | assert_last_visit_matches( | |||||||||
loader.storage, | loader.storage, | |||||||||
repo_url, | repo_url, | |||||||||
status="partial", | status="partial", | |||||||||
type="hg", | type="hg", | |||||||||
snapshot=hash_to_bytes("3b8fe58e467deb7597b12a5fd3b2c096b8c02028"), | snapshot=hash_to_bytes("3b8fe58e467deb7597b12a5fd3b2c096b8c02028"), | |||||||||
) | ) | |||||||||
def test_visit_error_with_status_not_found(swh_config, datadir, tmp_path, mocker): | ||||||||||
"""Not reaching the repo leads to a 'not_found' ingestion status""" | ||||||||||
mock = mocker.patch("hglib.clone") | ||||||||||
mock.side_effect = hglib.error.ResponseError() | ||||||||||
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": "uneventful"} | ||||||||||
assert_last_visit_matches( | ||||||||||
loader.storage, repo_url, status="not_found", type="hg", snapshot=None, | ||||||||||
) | ||||||||||
def test_visit_repository_with_transplant_operations(swh_config, datadir, tmp_path): | def test_visit_repository_with_transplant_operations(swh_config, datadir, tmp_path): | |||||||||
"""Visit a mercurial repository visit transplant operations within should yield a | """Visit a mercurial repository visit transplant operations within should yield a | |||||||||
snapshot as well. | snapshot as well. | |||||||||
""" | """ | |||||||||
archive_name = "transplant" | archive_name = "transplant" | |||||||||
archive_path = os.path.join(datadir, f"{archive_name}.tgz") | archive_path = os.path.join(datadir, f"{archive_name}.tgz") | |||||||||
repo_url = prepare_repository_from_archive(archive_path, archive_name, tmp_path) | repo_url = prepare_repository_from_archive(archive_path, archive_name, tmp_path) | |||||||||
loader = HgBundle20Loader(url=repo_url, visit_date="2019-05-23 12:06:00+00",) | loader = HgBundle20Loader(url=repo_url, visit_date="2019-05-23 12:06:00+00",) | |||||||||
vlorentzUnsubmitted Not Done Inline Actions
vlorentz: | ||||||||||
# load hg repository | # load hg repository | |||||||||
actual_load_status = loader.load() | actual_load_status = loader.load() | |||||||||
assert actual_load_status == {"status": "eventful"} | assert actual_load_status == {"status": "eventful"} | |||||||||
# collect swh revisions | # collect swh revisions | |||||||||
assert_last_visit_matches( | assert_last_visit_matches( | |||||||||
loader.storage, repo_url, type=RevisionType.MERCURIAL.value, status="full" | loader.storage, repo_url, type=RevisionType.MERCURIAL.value, status="full" | |||||||||
) | ) | |||||||||
revisions = [] | revisions = [] | |||||||||
snapshot = snapshot_get_latest(loader.storage, repo_url) | snapshot = snapshot_get_latest(loader.storage, repo_url) | |||||||||
for branch in snapshot.branches.values(): | for branch in snapshot.branches.values(): | |||||||||
if branch.target_type.value != "revision": | if branch.target_type.value != "revision": | |||||||||
continue | continue | |||||||||
revisions.append(branch.target) | revisions.append(branch.target) | |||||||||
Not Done Inline Actionsgood test, thanks :) vlorentz: good test, thanks :) | ||||||||||
# extract original changesets info and the transplant sources | # extract original changesets info and the transplant sources | |||||||||
hg_changesets = set() | hg_changesets = set() | |||||||||
transplant_sources = set() | transplant_sources = set() | |||||||||
for rev in loader.storage.revision_log(revisions): | for rev in loader.storage.revision_log(revisions): | |||||||||
hg_changesets.add(rev["metadata"]["node"]) | hg_changesets.add(rev["metadata"]["node"]) | |||||||||
for k, v in rev["extra_headers"]: | for k, v in rev["extra_headers"]: | |||||||||
if k == b"transplant_source": | if k == b"transplant_source": | |||||||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |