Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/debian/tests/test_debian.py
Show All 13 Lines | from swh.loader.package.debian.loader import ( | ||||
DebianLoader, | DebianLoader, | ||||
download_package, | download_package, | ||||
dsc_information, | dsc_information, | ||||
uid_to_person, | uid_to_person, | ||||
prepare_person, | prepare_person, | ||||
get_package_metadata, | get_package_metadata, | ||||
extract_package, | extract_package, | ||||
) | ) | ||||
from swh.loader.package.tests.common import check_snapshot, get_stats | from swh.loader.package.tests.common import ( | ||||
assert_last_visit_ok, | |||||
check_snapshot, | |||||
get_stats, | |||||
) | |||||
from swh.loader.package.debian.loader import resolve_revision_from | from swh.loader.package.debian.loader import resolve_revision_from | ||||
from swh.model.model import Person | from swh.model.model import Person | ||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | PACKAGES_PER_VERSION = { | ||||
"buster/contrib/0.7.2-4": PACKAGE_FILES2, | "buster/contrib/0.7.2-4": PACKAGE_FILES2, | ||||
} | } | ||||
def test_debian_first_visit(swh_config, requests_mock_datadir): | def test_debian_first_visit(swh_config, 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 | ||||
""" | """ | ||||
url = "deb://Debian/packages/cicero" | |||||
loader = DebianLoader( | loader = DebianLoader( | ||||
url="deb://Debian/packages/cicero", | url=url, date="2019-10-12T05:58:09.165557+00:00", packages=PACKAGE_PER_VERSION, | ||||
date="2019-10-12T05:58:09.165557+00:00", | |||||
packages=PACKAGE_PER_VERSION, | |||||
) | ) | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
expected_snapshot_id = "3b6b66e6ee4e7d903a379a882684a2a50480c0b4" | expected_snapshot_id = "3b6b66e6ee4e7d903a379a882684a2a50480c0b4" | ||||
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_ok(loader.storage, url, status="full", type="deb") | |||||
stats = get_stats(loader.storage) | stats = get_stats(loader.storage) | ||||
assert { | assert { | ||||
"content": 42, | "content": 42, | ||||
"directory": 2, | "directory": 2, | ||||
"origin": 1, | "origin": 1, | ||||
"origin_visit": 1, | "origin_visit": 1, | ||||
"person": 1, | "person": 1, | ||||
"release": 0, | "release": 0, | ||||
Show All 27 Lines | def test_debian_first_visit_then_another_visit(swh_config, requests_mock_datadir): | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
expected_snapshot_id = "3b6b66e6ee4e7d903a379a882684a2a50480c0b4" | expected_snapshot_id = "3b6b66e6ee4e7d903a379a882684a2a50480c0b4" | ||||
assert actual_load_status == { | assert actual_load_status == { | ||||
"status": "eventful", | "status": "eventful", | ||||
"snapshot_id": expected_snapshot_id, | "snapshot_id": expected_snapshot_id, | ||||
} | } | ||||
origin_visit = loader.storage.origin_visit_get_latest(url) | assert_last_visit_ok(loader.storage, url, status="full", type="deb") | ||||
assert origin_visit["status"] == "full" | |||||
assert origin_visit["type"] == "deb" | |||||
stats = get_stats(loader.storage) | stats = get_stats(loader.storage) | ||||
assert { | assert { | ||||
"content": 42, | "content": 42, | ||||
"directory": 2, | "directory": 2, | ||||
"origin": 1, | "origin": 1, | ||||
"origin_visit": 1, | "origin_visit": 1, | ||||
"person": 1, | "person": 1, | ||||
Show All 13 Lines | expected_snapshot = { | ||||
}, | }, | ||||
} # different than the previous loader as no release is done | } # different than the previous loader as no release is done | ||||
check_snapshot(expected_snapshot, loader.storage) | check_snapshot(expected_snapshot, loader.storage) | ||||
# No change in between load | # No change in between load | ||||
actual_load_status2 = loader.load() | actual_load_status2 = loader.load() | ||||
assert actual_load_status2["status"] == "uneventful" | assert actual_load_status2["status"] == "uneventful" | ||||
origin_visit2 = loader.storage.origin_visit_get_latest(url) | assert_last_visit_ok(loader.storage, url, status="full", type="deb") | ||||
assert origin_visit2["status"] == "full" | |||||
assert origin_visit2["type"] == "deb" | |||||
stats2 = get_stats(loader.storage) | stats2 = get_stats(loader.storage) | ||||
assert { | assert { | ||||
"content": 42 + 0, | "content": 42 + 0, | ||||
"directory": 2 + 0, | "directory": 2 + 0, | ||||
"origin": 1, | "origin": 1, | ||||
"origin_visit": 1 + 1, # a new visit occurred | "origin_visit": 1 + 1, # a new visit occurred | ||||
"person": 1, | "person": 1, | ||||
▲ Show 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | def test_debian_multiple_packages(swh_config, requests_mock_datadir): | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
expected_snapshot_id = "defc19021187f3727293121fcf6c5c82cb923604" | expected_snapshot_id = "defc19021187f3727293121fcf6c5c82cb923604" | ||||
assert actual_load_status == { | assert actual_load_status == { | ||||
"status": "eventful", | "status": "eventful", | ||||
"snapshot_id": expected_snapshot_id, | "snapshot_id": expected_snapshot_id, | ||||
} | } | ||||
origin_visit = loader.storage.origin_visit_get_latest(url) | assert_last_visit_ok(loader.storage, url, status="full", type="deb") | ||||
assert origin_visit["status"] == "full" | |||||
assert origin_visit["type"] == "deb" | |||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": expected_snapshot_id, | "id": expected_snapshot_id, | ||||
"branches": { | "branches": { | ||||
"releases/stretch/contrib/0.7.2-3": { | "releases/stretch/contrib/0.7.2-3": { | ||||
"target_type": "revision", | "target_type": "revision", | ||||
"target": "2807f5b3f84368b4889a9ae827fe85854ffecf07", | "target": "2807f5b3f84368b4889a9ae827fe85854ffecf07", | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |