Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/tests/test_loader.py
Show All 30 Lines | branches={ | ||||
b"HEAD": SnapshotBranch( | b"HEAD": SnapshotBranch( | ||||
target=hash_to_bytes("171dc35522bfd17dda4e90a542a0377fb2fc707a"), | target=hash_to_bytes("171dc35522bfd17dda4e90a542a0377fb2fc707a"), | ||||
target_type=TargetType.REVISION, | target_type=TargetType.REVISION, | ||||
) | ) | ||||
}, | }, | ||||
) | ) | ||||
def test_loader_svn_not_found(swh_config, tmp_path): | |||||
"""Given an unknown repository, the loader visit ends up in status not_found""" | |||||
unknown_repo_url = "unknown-repository" | |||||
loader = SvnLoader(unknown_repo_url, destination_path=tmp_path) | |||||
assert loader.load() == {"status": "uneventful"} | |||||
assert_last_visit_matches( | |||||
loader.storage, unknown_repo_url, status="not_found", type="svn", | |||||
) | |||||
def test_loader_svn_new_visit(swh_config, datadir, tmp_path): | def test_loader_svn_new_visit(swh_config, datadir, tmp_path): | ||||
"""Eventful visit should yield 1 snapshot""" | """Eventful visit should yield 1 snapshot""" | ||||
archive_name = "pkg-gourmet" | archive_name = "pkg-gourmet" | ||||
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 = SvnLoader(repo_url, destination_path=tmp_path) | loader = SvnLoader(repo_url, destination_path=tmp_path) | ||||
assert loader.load() == {"status": "eventful"} | assert loader.load() == {"status": "eventful"} | ||||
assert_last_visit_matches( | assert_last_visit_matches( | ||||
loader.storage, | loader.storage, | ||||
repo_url, | repo_url, | ||||
status="full", | status="full", | ||||
type="svn", | type="svn", | ||||
snapshot=GOURMET_SNAPSHOT.id, | snapshot=GOURMET_SNAPSHOT.id, | ||||
) | ) | ||||
stats = get_stats(loader.storage) | stats = get_stats(loader.storage) | ||||
assert stats == { | assert stats == { | ||||
"content": 19, | "content": 19, | ||||
"directory": 17, | "directory": 17, | ||||
"origin": 1, | "origin": 1, | ||||
vlorentz: "somehow" | |||||
"origin_visit": 1, | "origin_visit": 1, | ||||
"release": 0, | "release": 0, | ||||
"revision": 6, | "revision": 6, | ||||
"skipped_content": 0, | "skipped_content": 0, | ||||
"snapshot": 1, | "snapshot": 1, | ||||
} | } | ||||
check_snapshot(GOURMET_SNAPSHOT, loader.storage) | check_snapshot(GOURMET_SNAPSHOT, loader.storage) | ||||
▲ Show 20 Lines • Show All 558 Lines • Show Last 20 Lines |
"somehow"