feat(FastAPI): add /pkgbase/{name}/comments/{id}/pin (post)

In addition, fix up some templates to display pinned comments,
and include the unpin form input for pinned comments, which is
not yet implemented.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-10-01 15:47:16 -07:00
parent bb45ae7ac3
commit 0895dd07ee
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
5 changed files with 100 additions and 14 deletions

View file

@ -1143,3 +1143,29 @@ def test_pkgbase_comment_undelete_not_found(client: TestClient,
with client as request:
resp = request.post(endpoint, cookies=cookies)
assert resp.status_code == int(HTTPStatus.NOT_FOUND)
def test_pkgbase_comment_pin(client: TestClient,
maintainer: User,
package: Package,
comment: PackageComment):
cookies = {"AURSID": maintainer.login(Request(), "testPassword")}
comment_id = comment.ID
pkgbasename = package.PackageBase.Name
endpoint = f"/pkgbase/{pkgbasename}/comments/{comment_id}/pin"
with client as request:
resp = request.post(endpoint, cookies=cookies)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
def test_pkgbase_comment_pin_unauthorized(client: TestClient,
user: User,
package: Package,
comment: PackageComment):
cookies = {"AURSID": user.login(Request(), "testPassword")}
comment_id = comment.ID
pkgbasename = package.PackageBase.Name
endpoint = f"/pkgbase/{pkgbasename}/comments/{comment_id}/pin"
with client as request:
resp = request.post(endpoint, cookies=cookies)
assert resp.status_code == int(HTTPStatus.UNAUTHORIZED)