mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(rpc): correct URLPath in package results
This was incorrectly using the particular Package record's name to format options.snapshot_uri in order to produce URLPath. It should, instead, use the PackageBase record's name, which this commit resolves. Bug reported by thomy2000 Closes #382 Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
edacde48e5
commit
801df832e5
2 changed files with 23 additions and 1 deletions
|
@ -138,7 +138,7 @@ class RPC:
|
||||||
"Version": package.Version,
|
"Version": package.Version,
|
||||||
"Description": package.Description,
|
"Description": package.Description,
|
||||||
"URL": package.URL,
|
"URL": package.URL,
|
||||||
"URLPath": snapshot_uri % package.Name,
|
"URLPath": snapshot_uri % package.PackageBaseName,
|
||||||
"NumVotes": package.NumVotes,
|
"NumVotes": package.NumVotes,
|
||||||
"Popularity": pop,
|
"Popularity": pop,
|
||||||
"OutOfDate": package.OutOfDateTS,
|
"OutOfDate": package.OutOfDateTS,
|
||||||
|
|
|
@ -297,6 +297,28 @@ def test_rpc_singular_info(client: TestClient,
|
||||||
assert response_data == expected_data
|
assert response_data == expected_data
|
||||||
|
|
||||||
|
|
||||||
|
def test_rpc_split_package_urlpath(client: TestClient, user: User):
|
||||||
|
with db.begin():
|
||||||
|
pkgbase = db.create(PackageBase, Name="pkg",
|
||||||
|
Maintainer=user, Packager=user)
|
||||||
|
pkgs = [
|
||||||
|
db.create(Package, PackageBase=pkgbase, Name="pkg_1"),
|
||||||
|
db.create(Package, PackageBase=pkgbase, Name="pkg_2"),
|
||||||
|
]
|
||||||
|
|
||||||
|
with client as request:
|
||||||
|
response = request.get("/rpc", params={
|
||||||
|
"v": 5,
|
||||||
|
"type": "info",
|
||||||
|
"arg": [pkgs[0].Name],
|
||||||
|
})
|
||||||
|
|
||||||
|
data = orjson.loads(response.text)
|
||||||
|
snapshot_uri = config.get("options", "snapshot_uri")
|
||||||
|
urlpath = data.get("results")[0].get("URLPath")
|
||||||
|
assert urlpath == (snapshot_uri % pkgbase.Name)
|
||||||
|
|
||||||
|
|
||||||
def test_rpc_nonexistent_package(client: TestClient):
|
def test_rpc_nonexistent_package(client: TestClient):
|
||||||
# Make dummy request.
|
# Make dummy request.
|
||||||
with client as request:
|
with client as request:
|
||||||
|
|
Loading…
Add table
Reference in a new issue