Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/arch/tests/test_arch.py
Show All 17 Lines | |||||
) | ) | ||||
EXPECTED_PACKAGES = [ | EXPECTED_PACKAGES = [ | ||||
{ | { | ||||
"url": "https://archive.archlinux.org/packages/d/dialog/", | "url": "https://archive.archlinux.org/packages/d/dialog/", | ||||
"artifacts": [ | "artifacts": [ | ||||
{ | { | ||||
"url": "https://archive.archlinux.org/packages/d/dialog/dialog-1:1.3_20190211-1-x86_64.pkg.tar.xz", # noqa: B950 | "url": "https://archive.archlinux.org/packages/d/dialog/dialog-1:1.3_20190211-1-x86_64.pkg.tar.xz", # noqa: B950 | ||||
"version": "1:1.3_20190211-1", | |||||
"length": 180000, | |||||
"filename": "dialog-1:1.3_20190211-1-x86_64.pkg.tar.xz", | |||||
}, | |||||
{ | |||||
"url": "https://archive.archlinux.org/packages/d/dialog/dialog-1:1.3_20220414-1-x86_64.pkg.tar.zst", # noqa: B950 | |||||
"version": "1:1.3_20220414-1", | |||||
"length": 198000, | |||||
"filename": "dialog-1:1.3_20220414-1-x86_64.pkg.tar.zst", | |||||
}, | |||||
], | |||||
"arch_metadata": [ | |||||
{ | |||||
"arch": "x86_64", | "arch": "x86_64", | ||||
"repo": "core", | "repo": "core", | ||||
"name": "dialog", | "name": "dialog", | ||||
"version": "1:1.3_20190211-1", | "version": "1:1.3_20190211-1", | ||||
"length": 180000, | |||||
"filename": "dialog-1:1.3_20190211-1-x86_64.pkg.tar.xz", | |||||
"last_modified": "2019-02-13T08:36:00", | "last_modified": "2019-02-13T08:36:00", | ||||
}, | }, | ||||
{ | { | ||||
"url": "https://archive.archlinux.org/packages/d/dialog/dialog-1:1.3_20220414-1-x86_64.pkg.tar.zst", # noqa: B950 | |||||
"arch": "x86_64", | "arch": "x86_64", | ||||
"repo": "core", | "repo": "core", | ||||
"name": "dialog", | "name": "dialog", | ||||
"version": "1:1.3_20220414-1", | "version": "1:1.3_20220414-1", | ||||
"length": 198000, | |||||
"filename": "dialog-1:1.3_20220414-1-x86_64.pkg.tar.zst", | |||||
"last_modified": "2022-04-16T03:59:00", | "last_modified": "2022-04-16T03:59:00", | ||||
}, | }, | ||||
], | ], | ||||
}, | }, | ||||
{ | { | ||||
"url": "https://archlinuxarm.org/packages/aarch64/gzip", | "url": "https://archlinuxarm.org/packages/aarch64/gzip", | ||||
"artifacts": [ | "artifacts": [ | ||||
{ | { | ||||
"url": "https://uk.mirror.archlinuxarm.org/aarch64/core/gzip-1.12-1-aarch64.pkg.tar.xz", # noqa: B950 | "url": "https://uk.mirror.archlinuxarm.org/aarch64/core/gzip-1.12-1-aarch64.pkg.tar.xz", # noqa: B950 | ||||
"length": 79640, | |||||
"version": "1.12-1", | |||||
"filename": "gzip-1.12-1-aarch64.pkg.tar.xz", | |||||
} | |||||
], | |||||
"arch_metadata": [ | |||||
{ | |||||
"arch": "aarch64", | "arch": "aarch64", | ||||
"name": "gzip", | "name": "gzip", | ||||
"repo": "core", | "repo": "core", | ||||
"length": 79640, | |||||
"version": "1.12-1", | "version": "1.12-1", | ||||
"filename": "gzip-1.12-1-aarch64.pkg.tar.xz", | |||||
"last_modified": "2022-04-07T21:08:14", | "last_modified": "2022-04-07T21:08:14", | ||||
} | } | ||||
], | ], | ||||
}, | }, | ||||
] | ] | ||||
def test_get_versions(swh_storage): | def test_get_versions(swh_storage): | ||||
loader = ArchLoader( | loader = ArchLoader( | ||||
swh_storage, | swh_storage, | ||||
url=EXPECTED_PACKAGES[0]["url"], | url=EXPECTED_PACKAGES[0]["url"], | ||||
artifacts=EXPECTED_PACKAGES[0]["artifacts"], | artifacts=EXPECTED_PACKAGES[0]["artifacts"], | ||||
arch_metadata=EXPECTED_PACKAGES[0]["arch_metadata"], | |||||
) | ) | ||||
assert loader.get_versions() == [ | assert loader.get_versions() == [ | ||||
"1:1.3_20190211-1", | "1:1.3_20190211-1", | ||||
"1:1.3_20220414-1", | "1:1.3_20220414-1", | ||||
] | ] | ||||
def test_get_default_version(requests_mock_datadir, swh_storage): | def test_get_default_version(requests_mock_datadir, swh_storage): | ||||
loader = ArchLoader( | loader = ArchLoader( | ||||
swh_storage, | swh_storage, | ||||
url=EXPECTED_PACKAGES[0]["url"], | url=EXPECTED_PACKAGES[0]["url"], | ||||
artifacts=EXPECTED_PACKAGES[0]["artifacts"], | artifacts=EXPECTED_PACKAGES[0]["artifacts"], | ||||
arch_metadata=EXPECTED_PACKAGES[0]["arch_metadata"], | |||||
) | ) | ||||
assert loader.get_default_version() == "1:1.3_20220414-1" | assert loader.get_default_version() == "1:1.3_20220414-1" | ||||
def test_arch_loader_load_one_version(datadir, requests_mock_datadir, swh_storage): | def test_arch_loader_load_one_version(datadir, requests_mock_datadir, swh_storage): | ||||
loader = ArchLoader( | loader = ArchLoader( | ||||
swh_storage, | swh_storage, | ||||
url=EXPECTED_PACKAGES[1]["url"], | url=EXPECTED_PACKAGES[1]["url"], | ||||
artifacts=EXPECTED_PACKAGES[1]["artifacts"], | artifacts=EXPECTED_PACKAGES[1]["artifacts"], | ||||
arch_metadata=EXPECTED_PACKAGES[1]["arch_metadata"], | |||||
) | ) | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
assert actual_load_status["status"] == "eventful" | assert actual_load_status["status"] == "eventful" | ||||
assert actual_load_status["snapshot_id"] is not None | assert actual_load_status["snapshot_id"] is not None | ||||
expected_snapshot_id = "4020d0a278027550e336b5481a4159a913c91aa4" | expected_snapshot_id = "4020d0a278027550e336b5481a4159a913c91aa4" | ||||
expected_release_id = "7681098c9e381f9cc8bd1724d57eeee2182982dc" | expected_release_id = "7681098c9e381f9cc8bd1724d57eeee2182982dc" | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
def test_arch_loader_load_n_versions(datadir, requests_mock_datadir, swh_storage): | def test_arch_loader_load_n_versions(datadir, requests_mock_datadir, swh_storage): | ||||
loader = ArchLoader( | loader = ArchLoader( | ||||
swh_storage, | swh_storage, | ||||
url=EXPECTED_PACKAGES[0]["url"], | url=EXPECTED_PACKAGES[0]["url"], | ||||
artifacts=EXPECTED_PACKAGES[0]["artifacts"], | artifacts=EXPECTED_PACKAGES[0]["artifacts"], | ||||
arch_metadata=EXPECTED_PACKAGES[0]["arch_metadata"], | |||||
) | ) | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
assert actual_load_status["status"] == "eventful" | assert actual_load_status["status"] == "eventful" | ||||
assert actual_load_status["snapshot_id"] is not None | assert actual_load_status["snapshot_id"] is not None | ||||
expected_snapshot_id = "832139d69a91edffcc3a96cca11deaf9255041c3" | expected_snapshot_id = "832139d69a91edffcc3a96cca11deaf9255041c3" | ||||
assert expected_snapshot_id == actual_load_status["snapshot_id"] | assert expected_snapshot_id == actual_load_status["snapshot_id"] | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | def test_arch_invalid_origin_archive_not_found(swh_storage, requests_mock_datadir): | ||||
loader = ArchLoader( | loader = ArchLoader( | ||||
swh_storage, | swh_storage, | ||||
url, | url, | ||||
artifacts=[ | artifacts=[ | ||||
{ | { | ||||
"filename": "42-0.0.1.pkg.xz", | "filename": "42-0.0.1.pkg.xz", | ||||
"url": "https://mirror2.nowhere/pkg/42-0.0.1.pkg.xz", | "url": "https://mirror2.nowhere/pkg/42-0.0.1.pkg.xz", | ||||
"version": "0.0.1", | "version": "0.0.1", | ||||
"length": 42, | |||||
}, | |||||
], | |||||
arch_metadata=[ | |||||
{ | |||||
"version": "0.0.1", | |||||
"arch": "aarch64", | "arch": "aarch64", | ||||
"name": "42", | "name": "42", | ||||
"repo": "community", | "repo": "community", | ||||
"length": 42, | |||||
"last_modified": "2022-04-07T21:08:14", | "last_modified": "2022-04-07T21:08:14", | ||||
}, | }, | ||||
], | ], | ||||
) | ) | ||||
with pytest.raises(Exception): | with pytest.raises(Exception): | ||||
assert loader.load() == {"status": "failed"} | assert loader.load() == {"status": "failed"} | ||||
assert_last_visit_matches( | assert_last_visit_matches( | ||||
swh_storage, url, status="not_found", type="arch", snapshot=None | swh_storage, url, status="not_found", type="arch", snapshot=None | ||||
) | ) |