fix: search-by parameter for keyword links

Fixes:
Keyword-links on the package page pass wrong query-parameter.
Thus a name/description search is performed instead of  keywords

Issue report: #397

Signed-off-by: moson-mo <mo-son@mailbox.org>
This commit is contained in:
moson-mo 2022-11-27 10:33:58 +01:00
parent a08681ba23
commit 7864ac6dfe
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
2 changed files with 13 additions and 1 deletions

View file

@ -53,7 +53,7 @@
<td>
{% for keyword in pkgbase.keywords.all() %}
<a class="keyword"
href="/packages/?K={{ keyword.Keyword }}&amp;SB=p"
href="/packages/?K={{ keyword.Keyword }}&amp;SeB=k"
>
{{ keyword.Keyword }}
</a>

View file

@ -271,6 +271,13 @@ def test_package(client: TestClient, package: Package):
db.create(PackageLicense, PackageID=package.ID, License=licenses[0])
db.create(PackageLicense, PackageID=package.ID, License=licenses[1])
# Create some keywords
keywords = ["test1", "test2"]
for keyword in keywords:
db.create(
PackageKeyword, PackageBaseID=package.PackageBaseID, Keyword=keyword
)
with client as request:
resp = request.get(package_endpoint(package))
assert resp.status_code == int(HTTPStatus.OK)
@ -307,6 +314,11 @@ def test_package(client: TestClient, package: Package):
expected = ["test_conflict1", "test_conflict2"]
assert conflicts[0].text.strip() == ", ".join(expected)
keywords = root.xpath('//a[@class="keyword"]')
expected = ["test1", "test2"]
for i, keyword in enumerate(expected):
assert keywords[i].text.strip() == keyword
def test_package_split_description(client: TestClient, user: User):