From 7864ac6dfeafd3995063e3b58cfbd393fb1b6551 Mon Sep 17 00:00:00 2001 From: moson-mo Date: Sun, 27 Nov 2022 10:33:58 +0100 Subject: [PATCH] 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 --- templates/partials/packages/details.html | 2 +- test/test_packages_routes.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/templates/partials/packages/details.html b/templates/partials/packages/details.html index 8ecf9bd8..697ef724 100644 --- a/templates/partials/packages/details.html +++ b/templates/partials/packages/details.html @@ -53,7 +53,7 @@ {% for keyword in pkgbase.keywords.all() %} {{ keyword.Keyword }} diff --git a/test/test_packages_routes.py b/test/test_packages_routes.py index c8986b9c..bf179963 100644 --- a/test/test_packages_routes.py +++ b/test/test_packages_routes.py @@ -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):