Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/aur/tests/test_aur.py
# Copyright (C) 2022 The Software Heritage developers | # Copyright (C) 2022 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from swh.loader.package.aur.loader import AurLoader | from swh.loader.package.aur.loader import AurLoader | ||||
from swh.loader.package.utils import EMPTY_AUTHOR | from swh.loader.package.utils import EMPTY_AUTHOR | ||||
from swh.loader.tests import assert_last_visit_matches, check_snapshot, get_stats | from swh.loader.tests import assert_last_visit_matches, check_snapshot, get_stats | ||||
from swh.model.hashutil import hash_to_bytes | from swh.model.hashutil import hash_to_bytes | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
ObjectType, | ObjectType, | ||||
Release, | Release, | ||||
Snapshot, | Snapshot, | ||||
SnapshotBranch, | SnapshotBranch, | ||||
TargetType, | TargetType, | ||||
TimestampWithTimezone, | TimestampWithTimezone, | ||||
) | ) | ||||
EXPECTED_PACKAGES = [ | EXPECTED_PACKAGES = [ | ||||
{ | { | ||||
"url": "https://aur.archlinux.org/hg-evolve.git", | "url": "https://aur.archlinux.org/hg-evolve.git", | ||||
"artifacts": [ | "artifacts": { | ||||
{ | "10.5.2-1": { | ||||
"filename": "hg-evolve.tar.gz", | "filename": "hg-evolve.tar.gz", | ||||
"url": "https://aur.archlinux.org/cgit/aur.git/snapshot/hg-evolve.tar.gz", # noqa: B950 | "url": "https://aur.archlinux.org/cgit/aur.git/snapshot/hg-evolve.tar.gz", # noqa: B950 | ||||
"version": "10.5.2-1", | "version": "10.5.2-1", | ||||
} | } | ||||
], | }, | ||||
"aur_metadata": [ | "aur_metadata": { | ||||
{ | "10.5.2-1": { | ||||
"version": "10.5.2-1", | "version": "10.5.2-1", | ||||
"project_url": "https://www.mercurial-scm.org/doc/evolution/", | "project_url": "https://www.mercurial-scm.org/doc/evolution/", | ||||
"last_update": "2022-07-16T00:08:41+00:00", | "last_update": "2022-07-16T00:08:41+00:00", | ||||
"pkgname": "hg-evolve", | "pkgname": "hg-evolve", | ||||
} | } | ||||
], | }, | ||||
}, | }, | ||||
{ | { | ||||
"url": "https://aur.archlinux.org/ibus-git.git", | "url": "https://aur.archlinux.org/ibus-git.git", | ||||
"artifacts": [ | "artifacts": { | ||||
{ | "1.5.23+12+gef4c5c7e-1": { | ||||
"filename": "ibus-git.tar.gz", | "filename": "ibus-git.tar.gz", | ||||
"url": "https://aur.archlinux.org/cgit/aur.git/snapshot/ibus-git.tar.gz", # noqa: B950 | "url": "https://aur.archlinux.org/cgit/aur.git/snapshot/ibus-git.tar.gz", # noqa: B950 | ||||
"version": "1.5.23+12+gef4c5c7e-1", | "version": "1.5.23+12+gef4c5c7e-1", | ||||
} | } | ||||
], | }, | ||||
"aur_metadata": [ | "aur_metadata": { | ||||
{ | "1.5.23+12+gef4c5c7e-1": { | ||||
"version": "1.5.23+12+gef4c5c7e-1", | "version": "1.5.23+12+gef4c5c7e-1", | ||||
"project_url": "https://github.com/ibus/ibus/wiki", | "project_url": "https://github.com/ibus/ibus/wiki", | ||||
"last_update": "2021-02-08T06:12:11+00:00", | "last_update": "2021-02-08T06:12:11+00:00", | ||||
"pkgname": "ibus-git", | "pkgname": "ibus-git", | ||||
} | } | ||||
], | }, | ||||
}, | }, | ||||
{ | { | ||||
"url": "https://aur.archlinux.org/libervia-web-hg.git", | "url": "https://aur.archlinux.org/libervia-web-hg.git", | ||||
"artifacts": [ | "artifacts": { | ||||
{ | "0.9.0.r1492.3a34d78f2717-1": { | ||||
"filename": "libervia-web-hg.tar.gz", | "filename": "libervia-web-hg.tar.gz", | ||||
"url": "https://aur.archlinux.org/cgit/aur.git/snapshot/libervia-web-hg.tar.gz", # noqa: B950 | "url": "https://aur.archlinux.org/cgit/aur.git/snapshot/libervia-web-hg.tar.gz", # noqa: B950 | ||||
"version": "0.9.0.r1492.3a34d78f2717-1", | "version": "0.9.0.r1492.3a34d78f2717-1", | ||||
} | } | ||||
], | }, | ||||
"aur_metadata": [ | "aur_metadata": { | ||||
{ | "0.9.0.r1492.3a34d78f2717-1": { | ||||
"version": "0.9.0.r1492.3a34d78f2717-1", | "version": "0.9.0.r1492.3a34d78f2717-1", | ||||
"project_url": "http://salut-a-toi.org/", | "project_url": "http://salut-a-toi.org/", | ||||
"last_update": "2022-02-26T15:30:58+00:00", | "last_update": "2022-02-26T15:30:58+00:00", | ||||
"pkgname": "libervia-web-hg", | "pkgname": "libervia-web-hg", | ||||
} | } | ||||
], | }, | ||||
}, | }, | ||||
{ | { | ||||
"url": "https://aur.archlinux.org/tealdeer-git.git", | "url": "https://aur.archlinux.org/tealdeer-git.git", | ||||
"artifacts": [ | "artifacts": { | ||||
{ | "r255.30b7c5f-1": { | ||||
"filename": "tealdeer-git.tar.gz", | "filename": "tealdeer-git.tar.gz", | ||||
"url": "https://aur.archlinux.org/cgit/aur.git/snapshot/tealdeer-git.tar.gz", # noqa: B950 | "url": "https://aur.archlinux.org/cgit/aur.git/snapshot/tealdeer-git.tar.gz", # noqa: B950 | ||||
"version": "r255.30b7c5f-1", | "version": "r255.30b7c5f-1", | ||||
} | } | ||||
], | }, | ||||
"aur_metadata": [ | "aur_metadata": { | ||||
{ | "r255.30b7c5f-1": { | ||||
"version": "r255.30b7c5f-1", | "version": "r255.30b7c5f-1", | ||||
"project_url": "https://github.com/dbrgn/tealdeer", | "project_url": "https://github.com/dbrgn/tealdeer", | ||||
"last_update": "2020-09-04T20:36:52+00:00", | "last_update": "2020-09-04T20:36:52+00:00", | ||||
"pkgname": "tealdeer-git", | "pkgname": "tealdeer-git", | ||||
} | } | ||||
], | }, | ||||
}, | }, | ||||
{ | { | ||||
"url": "https://aur.archlinux.org/a-fake-one.git", | "url": "https://aur.archlinux.org/a-fake-one.git", | ||||
"artifacts": [ | "artifacts": { | ||||
{ | "0.0.1": { | ||||
"filename": "a-fake-one.tar.gz", | "filename": "a-fake-one.tar.gz", | ||||
"url": "https://aur.archlinux.org/cgit/aur.git/snapshot/a-fake-one.tar.gz", # noqa: B950 | "url": "https://aur.archlinux.org/cgit/aur.git/snapshot/a-fake-one.tar.gz", # noqa: B950 | ||||
"version": "0.0.1", | "version": "0.0.1", | ||||
}, | }, | ||||
], | }, | ||||
"aur_metadata": [ | "aur_metadata": { | ||||
{ | "0.0.1": { | ||||
"version": "0.0.1", | "version": "0.0.1", | ||||
"project_url": "https://nowhere/a-fake-one", | "project_url": "https://nowhere/a-fake-one", | ||||
"last_update": "2022-02-02T22:22:22+00:00", | "last_update": "2022-02-02T22:22:22+00:00", | ||||
"pkgname": "a-fake-one", | "pkgname": "a-fake-one", | ||||
} | } | ||||
], | }, | ||||
}, | }, | ||||
] | ] | ||||
def test_get_versions(swh_storage): | def test_get_versions(swh_storage): | ||||
loader = AurLoader( | loader = AurLoader( | ||||
swh_storage, | swh_storage, | ||||
url=EXPECTED_PACKAGES[0]["url"], | url=EXPECTED_PACKAGES[0]["url"], | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | def test_aur_loader_load_expected_packages(datadir, requests_mock_datadir, swh_storage): | ||||
} == stats | } == stats | ||||
def test_aur_invalid_origin_not_found(swh_storage, requests_mock_datadir): | def test_aur_invalid_origin_not_found(swh_storage, requests_mock_datadir): | ||||
url = "http://nowhere/packages/42.git" | url = "http://nowhere/packages/42.git" | ||||
loader = AurLoader( | loader = AurLoader( | ||||
swh_storage, | swh_storage, | ||||
url, | url, | ||||
artifacts=[ | artifacts={ | ||||
{ | "0.0.1": { | ||||
"version": "0.0.1", | "version": "0.0.1", | ||||
"url": "https://myforge.nowhere/42/42.tar.gz", | "url": "https://myforge.nowhere/42/42.tar.gz", | ||||
"filename": "42.tar.gz", | "filename": "42.tar.gz", | ||||
}, | }, | ||||
], | }, | ||||
aur_metadata=[ | aur_metadata={ | ||||
{ | "0.0.1": { | ||||
"pkgname": "42", | "pkgname": "42", | ||||
"version": "0.0.1", | "version": "0.0.1", | ||||
"project_url": "https://myforge.nowhere/42", | "project_url": "https://myforge.nowhere/42", | ||||
"last_update": "2022-04-07T21:08:14", | "last_update": "2022-04-07T21:08:14", | ||||
}, | }, | ||||
], | }, | ||||
) | ) | ||||
load_status = loader.load() | load_status = loader.load() | ||||
assert load_status["status"] == "uneventful" | assert load_status["status"] == "uneventful" | ||||
def test_aur_parse_srcinfo(swh_storage, requests_mock_datadir): | def test_aur_parse_srcinfo(swh_storage, requests_mock_datadir): | ||||
"""Ensure that multiple lines of `pkgdesc` in .SRCINFO results in `description` | """Ensure that multiple lines of `pkgdesc` in .SRCINFO results in `description` | ||||
Show All 23 Lines |