Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/cpan/tests/test_cpan.py
Show All 40 Lines | def test_cpan_loader_load_multiple_version(datadir, requests_mock_datadir, swh_storage): | ||||
loader = CpanLoader( | loader = CpanLoader( | ||||
swh_storage, | swh_storage, | ||||
url=ORIGINS[0], | url=ORIGINS[0], | ||||
) | ) | ||||
load_status = loader.load() | load_status = loader.load() | ||||
assert load_status["status"] == "eventful" | assert load_status["status"] == "eventful" | ||||
assert load_status["snapshot_id"] is not None | assert load_status["snapshot_id"] is not None | ||||
expected_snapshot_id = "2b1f606033ef5ccfed78aeb94baf5a8b901b2306" | expected_snapshot_id = "848ee8d69d33481c88ab81f6794f6504190f011f" | ||||
assert expected_snapshot_id == load_status["snapshot_id"] | assert expected_snapshot_id == load_status["snapshot_id"] | ||||
expected_snapshot = Snapshot( | expected_snapshot = Snapshot( | ||||
id=hash_to_bytes(load_status["snapshot_id"]), | id=hash_to_bytes(load_status["snapshot_id"]), | ||||
branches={ | branches={ | ||||
b"releases/0.01": SnapshotBranch( | b"releases/0.01": SnapshotBranch( | ||||
target=hash_to_bytes("3b31ce005c364de6c1b8caca8bf12487d5debf38"), | target=hash_to_bytes("e73aced4cc3d56b32a328d3248b25b052f029df4"), | ||||
target_type=TargetType.RELEASE, | target_type=TargetType.RELEASE, | ||||
), | ), | ||||
b"releases/0.05": SnapshotBranch( | b"releases/0.05": SnapshotBranch( | ||||
target=hash_to_bytes("2901106d99de31f71380b6c3b5e92799ce3a1a5e"), | target=hash_to_bytes("07382fd255ec0fc293b92aeb7e68b3fe31c174f9"), | ||||
target_type=TargetType.RELEASE, | target_type=TargetType.RELEASE, | ||||
), | ), | ||||
b"HEAD": SnapshotBranch( | b"HEAD": SnapshotBranch( | ||||
target=b"releases/0.05", | target=b"releases/0.05", | ||||
target_type=TargetType.ALIAS, | target_type=TargetType.ALIAS, | ||||
), | ), | ||||
}, | }, | ||||
) | ) | ||||
check_snapshot(expected_snapshot, swh_storage) | check_snapshot(expected_snapshot, swh_storage) | ||||
stats = get_stats(swh_storage) | stats = get_stats(swh_storage) | ||||
assert { | assert { | ||||
"content": 2, | "content": 2, | ||||
"directory": 4, | "directory": 4, | ||||
"origin": 1, | "origin": 1, | ||||
"origin_visit": 1, | "origin_visit": 1, | ||||
"release": 2, | "release": 2, | ||||
"revision": 0, | "revision": 0, | ||||
"skipped_content": 0, | "skipped_content": 0, | ||||
"snapshot": 1, | "snapshot": 1, | ||||
} == stats | } == stats | ||||
assert swh_storage.release_get( | assert swh_storage.release_get( | ||||
[hash_to_bytes("2901106d99de31f71380b6c3b5e92799ce3a1a5e")] | [hash_to_bytes("07382fd255ec0fc293b92aeb7e68b3fe31c174f9")] | ||||
)[0] == Release( | )[0] == Release( | ||||
name=b"0.05", | name=b"0.05", | ||||
message=b"Synthetic release for Perl source package Internals-CountObjects" | message=b"Synthetic release for Perl source package Internals-CountObjects" | ||||
b" version 0.05\n\nReport all allocated perl objects\n", | b" version 0.05\n", | ||||
target=hash_to_bytes("af3f6a43eaf4b26dbcadb1101e8d81db6d6151e0"), | target=hash_to_bytes("af3f6a43eaf4b26dbcadb1101e8d81db6d6151e0"), | ||||
target_type=ObjectType.DIRECTORY, | target_type=ObjectType.DIRECTORY, | ||||
synthetic=True, | synthetic=True, | ||||
author=Person( | author=Person( | ||||
fullname=b"Josh Jore <jjore@cpan.org>", | fullname=b"Josh Jore <jjore@cpan.org>", | ||||
name=b"Josh Jore", | name=b"Josh Jore", | ||||
email=b"jjore@cpan.org", | email=b"jjore@cpan.org", | ||||
), | ), | ||||
date=TimestampWithTimezone.from_iso8601("2011-06-11T05:23:31+00:00"), | date=TimestampWithTimezone.from_iso8601("2011-06-11T05:23:31+00:00"), | ||||
id=hash_to_bytes("2901106d99de31f71380b6c3b5e92799ce3a1a5e"), | id=hash_to_bytes("07382fd255ec0fc293b92aeb7e68b3fe31c174f9"), | ||||
) | ) | ||||
assert_last_visit_matches( | assert_last_visit_matches( | ||||
swh_storage, | swh_storage, | ||||
url=ORIGINS[0], | url=ORIGINS[0], | ||||
status="full", | status="full", | ||||
type="cpan", | type="cpan", | ||||
snapshot=expected_snapshot.id, | snapshot=expected_snapshot.id, | ||||
) | ) |