Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/mercurial/tests/test_from_disk.py
Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | assert_last_visit_matches( | ||||||||||
repo_url, | repo_url, | ||||||||||
status="full", | status="full", | ||||||||||
type="hg", | type="hg", | ||||||||||
snapshot=expected_snapshot.id, | snapshot=expected_snapshot.id, | ||||||||||
) | ) | ||||||||||
check_snapshot(expected_snapshot, loader.storage) | check_snapshot(expected_snapshot, loader.storage) | ||||||||||
stats = get_stats(loader.storage) | stats = get_stats(loader.storage) | ||||||||||
assert stats == { | expected_stats = { | ||||||||||
"content": 2, | "content": 2, | ||||||||||
"directory": 3, | "directory": 3, | ||||||||||
"origin": 1, | "origin": 1, | ||||||||||
"origin_visit": 1, | "origin_visit": 1, | ||||||||||
"release": 0, | "release": 0, | ||||||||||
"revision": 58, | "revision": 58, | ||||||||||
"skipped_content": 0, | "skipped_content": 0, | ||||||||||
"snapshot": 1, | "snapshot": 1, | ||||||||||
} | } | ||||||||||
assert stats == expected_stats | |||||||||||
loader2 = HgLoaderFromDisk(swh_storage, url=repo_url) | |||||||||||
assert loader2.load() == {"status": "uneventful"} | |||||||||||
stats2 = get_stats(loader2.storage) | |||||||||||
expected_stats2 = expected_stats.copy() | |||||||||||
expected_stats2["origin_visit"] = 2 # one new visit recorded | |||||||||||
assert stats2 == expected_stats2 | |||||||||||
olasdUnsubmitted Done Inline Actions
olasd: | |||||||||||
visit_status = assert_last_visit_matches( | |||||||||||
loader2.storage, repo_url, status="full", type="hg", | |||||||||||
) | |||||||||||
Done Inline ActionsIf there was no filtering whatsoever, we would expect the result of the second load to be exactly the same result as the first one (i.e. the same snapshot, with the exact same underlying objects). In effect, the counters should not change between the first and the second load (except for one more OriginVisit). The issue that I think you had pointed out, was that the final OriginVisitStatus of the second OriginVisit didn't get a snapshot entry. So you need to add a check for that. olasd: If there was no filtering whatsoever, we would expect the result of the second load to be… | |||||||||||
Done Inline ActionsTotally agreed! Thanks. I've updated the diff to that effect. ardumont: Totally agreed! Thanks.
I've updated the diff to that effect. | |||||||||||
assert visit_status.snapshot is None | |||||||||||
# FIXME: Already seen objects are filtered out, so no new snapshot. | |||||||||||
# Current behavior but is it ok? | |||||||||||
# This test has as been adapted from the historical `HgBundle20Loader` tests | # This test has as been adapted from the historical `HgBundle20Loader` tests | ||||||||||
# to ensure compatibility of `HgLoaderFromDisk`. | # to ensure compatibility of `HgLoaderFromDisk`. | ||||||||||
# Hashes as been produced by copy pasting the result of the implementation | # Hashes as been produced by copy pasting the result of the implementation | ||||||||||
# to prevent regressions. | # to prevent regressions. | ||||||||||
def test_loader_hg_new_visit_with_release(swh_storage, datadir, tmp_path): | def test_loader_hg_new_visit_with_release(swh_storage, datadir, tmp_path): | ||||||||||
"""Eventful visit with release should yield 1 snapshot""" | """Eventful visit with release should yield 1 snapshot""" | ||||||||||
▲ Show 20 Lines • Show All 488 Lines • Show Last 20 Lines |