Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/debian/tests/test_debian.py
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | |||||
def test_debian_first_visit(swh_storage, requests_mock_datadir): | def test_debian_first_visit(swh_storage, requests_mock_datadir): | ||||
"""With no prior visit, load a gnu project ends up with 1 snapshot | """With no prior visit, load a gnu project ends up with 1 snapshot | ||||
""" | """ | ||||
loader = DebianLoader(swh_storage, URL, packages=PACKAGE_PER_VERSION,) | loader = DebianLoader(swh_storage, URL, packages=PACKAGE_PER_VERSION,) | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
expected_snapshot_id = "ad1367b5470a03857be7c7325a5a8bde698e1800" | expected_snapshot_id = "f9e4d0d200433dc998ad2ca40ee1244785fe6ed1" | ||||
assert actual_load_status == { | assert actual_load_status == { | ||||
"status": "eventful", | "status": "eventful", | ||||
"snapshot_id": expected_snapshot_id, | "snapshot_id": expected_snapshot_id, | ||||
} | } | ||||
assert_last_visit_matches( | assert_last_visit_matches( | ||||
swh_storage, | swh_storage, | ||||
URL, | URL, | ||||
status="full", | status="full", | ||||
type="deb", | type="deb", | ||||
snapshot=hash_to_bytes(expected_snapshot_id), | snapshot=hash_to_bytes(expected_snapshot_id), | ||||
) | ) | ||||
release_id = hash_to_bytes("73e0ede9c21f7074ad1f9c81a774cfcb9e02addf") | release_id = hash_to_bytes("de96ae3d3e136f5c1709117059e2a2c05b8ee5ae") | ||||
expected_snapshot = Snapshot( | expected_snapshot = Snapshot( | ||||
id=hash_to_bytes(expected_snapshot_id), | id=hash_to_bytes(expected_snapshot_id), | ||||
branches={ | branches={ | ||||
b"releases/stretch/contrib/0.7.2-3": SnapshotBranch( | b"releases/stretch/contrib/0.7.2-3": SnapshotBranch( | ||||
target_type=TargetType.RELEASE, target=release_id, | target_type=TargetType.RELEASE, target=release_id, | ||||
) | ) | ||||
}, | }, | ||||
) # different than the previous loader as no release is done | ) # different than the previous loader as no release is done | ||||
check_snapshot(expected_snapshot, swh_storage) | check_snapshot(expected_snapshot, swh_storage) | ||||
assert swh_storage.release_get([release_id])[0] == Release( | assert swh_storage.release_get([release_id])[0] == Release( | ||||
id=release_id, | id=release_id, | ||||
name=b"stretch/contrib/0.7.2-3", | name=b"0.7.2-3", | ||||
message=b"Synthetic release for Debian source package cicero version 0.7.2-3\n", | message=b"Synthetic release for Debian source package cicero version 0.7.2-3\n", | ||||
target=hash_to_bytes("798df511408c53bf842a8e54d4d335537836bdc3"), | target=hash_to_bytes("798df511408c53bf842a8e54d4d335537836bdc3"), | ||||
target_type=ObjectType.DIRECTORY, | target_type=ObjectType.DIRECTORY, | ||||
synthetic=True, | synthetic=True, | ||||
author=Person( | author=Person( | ||||
fullname=b"Samuel Thibault <sthibault@debian.org>", | fullname=b"Samuel Thibault <sthibault@debian.org>", | ||||
name=b"Samuel Thibault", | name=b"Samuel Thibault", | ||||
email=b"sthibault@debian.org", | email=b"sthibault@debian.org", | ||||
Show All 21 Lines | |||||
def test_debian_first_visit_then_another_visit(swh_storage, requests_mock_datadir): | def test_debian_first_visit_then_another_visit(swh_storage, requests_mock_datadir): | ||||
"""With no prior visit, load a debian project ends up with 1 snapshot | """With no prior visit, load a debian project ends up with 1 snapshot | ||||
""" | """ | ||||
loader = DebianLoader(swh_storage, URL, packages=PACKAGE_PER_VERSION,) | loader = DebianLoader(swh_storage, URL, packages=PACKAGE_PER_VERSION,) | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
expected_snapshot_id = "ad1367b5470a03857be7c7325a5a8bde698e1800" | expected_snapshot_id = "f9e4d0d200433dc998ad2ca40ee1244785fe6ed1" | ||||
assert actual_load_status == { | assert actual_load_status == { | ||||
"status": "eventful", | "status": "eventful", | ||||
"snapshot_id": expected_snapshot_id, | "snapshot_id": expected_snapshot_id, | ||||
} | } | ||||
assert_last_visit_matches( | assert_last_visit_matches( | ||||
swh_storage, | swh_storage, | ||||
URL, | URL, | ||||
status="full", | status="full", | ||||
type="deb", | type="deb", | ||||
snapshot=hash_to_bytes(expected_snapshot_id), | snapshot=hash_to_bytes(expected_snapshot_id), | ||||
) | ) | ||||
expected_snapshot = Snapshot( | expected_snapshot = Snapshot( | ||||
id=hash_to_bytes(expected_snapshot_id), | id=hash_to_bytes(expected_snapshot_id), | ||||
branches={ | branches={ | ||||
b"releases/stretch/contrib/0.7.2-3": SnapshotBranch( | b"releases/stretch/contrib/0.7.2-3": SnapshotBranch( | ||||
target_type=TargetType.RELEASE, | target_type=TargetType.RELEASE, | ||||
target=hash_to_bytes("73e0ede9c21f7074ad1f9c81a774cfcb9e02addf"), | target=hash_to_bytes("de96ae3d3e136f5c1709117059e2a2c05b8ee5ae"), | ||||
) | ) | ||||
}, | }, | ||||
) # different than the previous loader as no release is done | ) # different than the previous loader as no release is done | ||||
check_snapshot(expected_snapshot, swh_storage) | check_snapshot(expected_snapshot, swh_storage) | ||||
stats = get_stats(swh_storage) | stats = get_stats(swh_storage) | ||||
assert { | assert { | ||||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | assert actual_package_info == IntrinsicPackageMetadata( | ||||
version="0.7.2-3", | version="0.7.2-3", | ||||
) | ) | ||||
def test_debian_multiple_packages(swh_storage, requests_mock_datadir): | def test_debian_multiple_packages(swh_storage, requests_mock_datadir): | ||||
loader = DebianLoader(swh_storage, URL, packages=PACKAGES_PER_VERSION,) | loader = DebianLoader(swh_storage, URL, packages=PACKAGES_PER_VERSION,) | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
expected_snapshot_id = "a83fa5c089b048161f0677b9614a4aae96a6ca18" | expected_snapshot_id = "474c0e3d5796d15363031c333533527d659c559e" | ||||
assert actual_load_status == { | assert actual_load_status == { | ||||
"status": "eventful", | "status": "eventful", | ||||
"snapshot_id": expected_snapshot_id, | "snapshot_id": expected_snapshot_id, | ||||
} | } | ||||
assert_last_visit_matches( | assert_last_visit_matches( | ||||
swh_storage, | swh_storage, | ||||
URL, | URL, | ||||
status="full", | status="full", | ||||
type="deb", | type="deb", | ||||
snapshot=hash_to_bytes(expected_snapshot_id), | snapshot=hash_to_bytes(expected_snapshot_id), | ||||
) | ) | ||||
expected_snapshot = Snapshot( | expected_snapshot = Snapshot( | ||||
id=hash_to_bytes(expected_snapshot_id), | id=hash_to_bytes(expected_snapshot_id), | ||||
branches={ | branches={ | ||||
b"releases/stretch/contrib/0.7.2-3": SnapshotBranch( | b"releases/stretch/contrib/0.7.2-3": SnapshotBranch( | ||||
target_type=TargetType.RELEASE, | target_type=TargetType.RELEASE, | ||||
target=hash_to_bytes("73e0ede9c21f7074ad1f9c81a774cfcb9e02addf"), | target=hash_to_bytes("de96ae3d3e136f5c1709117059e2a2c05b8ee5ae"), | ||||
), | ), | ||||
b"releases/buster/contrib/0.7.2-4": SnapshotBranch( | b"releases/buster/contrib/0.7.2-4": SnapshotBranch( | ||||
target_type=TargetType.RELEASE, | target_type=TargetType.RELEASE, | ||||
target=hash_to_bytes("9f6d8d868514f991af0d9f5d7173aba1236a5a75"), | target=hash_to_bytes("11824484c585319302ea4fde4917faf78dfb1973"), | ||||
), | ), | ||||
}, | }, | ||||
) | ) | ||||
check_snapshot(expected_snapshot, swh_storage) | check_snapshot(expected_snapshot, swh_storage) | ||||
def test_debian_loader_only_md5_sum_in_dsc(swh_storage, requests_mock_datadir): | def test_debian_loader_only_md5_sum_in_dsc(swh_storage, requests_mock_datadir): | ||||
packages_per_version = deepcopy(PACKAGES_PER_VERSION) | packages_per_version = deepcopy(PACKAGES_PER_VERSION) | ||||
for package_files in packages_per_version.values(): | for package_files in packages_per_version.values(): | ||||
for package_data in package_files["files"].values(): | for package_data in package_files["files"].values(): | ||||
del package_data["sha256"] | del package_data["sha256"] | ||||
loader = DebianLoader(swh_storage, URL, packages=packages_per_version) | loader = DebianLoader(swh_storage, URL, packages=packages_per_version) | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
expected_snapshot_id = "a83fa5c089b048161f0677b9614a4aae96a6ca18" | expected_snapshot_id = "474c0e3d5796d15363031c333533527d659c559e" | ||||
assert actual_load_status == { | assert actual_load_status == { | ||||
"status": "eventful", | "status": "eventful", | ||||
"snapshot_id": expected_snapshot_id, | "snapshot_id": expected_snapshot_id, | ||||
} | } | ||||
assert_last_visit_matches( | assert_last_visit_matches( | ||||
swh_storage, | swh_storage, | ||||
URL, | URL, | ||||
status="full", | status="full", | ||||
type="deb", | type="deb", | ||||
snapshot=hash_to_bytes(expected_snapshot_id), | snapshot=hash_to_bytes(expected_snapshot_id), | ||||
) | ) | ||||
expected_snapshot = Snapshot( | expected_snapshot = Snapshot( | ||||
id=hash_to_bytes(expected_snapshot_id), | id=hash_to_bytes(expected_snapshot_id), | ||||
branches={ | branches={ | ||||
b"releases/stretch/contrib/0.7.2-3": SnapshotBranch( | b"releases/stretch/contrib/0.7.2-3": SnapshotBranch( | ||||
target_type=TargetType.RELEASE, | target_type=TargetType.RELEASE, | ||||
target=hash_to_bytes("73e0ede9c21f7074ad1f9c81a774cfcb9e02addf"), | target=hash_to_bytes("de96ae3d3e136f5c1709117059e2a2c05b8ee5ae"), | ||||
), | ), | ||||
b"releases/buster/contrib/0.7.2-4": SnapshotBranch( | b"releases/buster/contrib/0.7.2-4": SnapshotBranch( | ||||
target_type=TargetType.RELEASE, | target_type=TargetType.RELEASE, | ||||
target=hash_to_bytes("9f6d8d868514f991af0d9f5d7173aba1236a5a75"), | target=hash_to_bytes("11824484c585319302ea4fde4917faf78dfb1973"), | ||||
), | ), | ||||
}, | }, | ||||
) | ) | ||||
check_snapshot(expected_snapshot, swh_storage) | check_snapshot(expected_snapshot, swh_storage) |