fix: allow co-maintainers to [un]pin comments on a package

Closes #279

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2022-02-11 15:57:52 -08:00
parent 35e7486ea3
commit 708ade4dbf
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
6 changed files with 47 additions and 8 deletions

View file

@ -534,6 +534,35 @@ def test_pkgbase_comment_undelete_not_found(client: TestClient,
assert resp.status_code == int(HTTPStatus.NOT_FOUND)
def test_pkgbase_comment_pin_as_co(client: TestClient, package: Package,
comment: PackageComment):
comaint = create_user("comaint1")
with db.begin():
db.create(PackageComaintainer, PackageBase=package.PackageBase,
User=comaint, Priority=1)
# Pin the comment.
pkgbasename = package.PackageBase.Name
endpoint = f"/pkgbase/{pkgbasename}/comments/{comment.ID}/pin"
cookies = {"AURSID": comaint.login(Request(), "testPassword")}
with client as request:
resp = request.post(endpoint, cookies=cookies)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
# Assert that PinnedTS got set.
assert comment.PinnedTS > 0
# Unpin the comment we just pinned.
endpoint = f"/pkgbase/{pkgbasename}/comments/{comment.ID}/unpin"
with client as request:
resp = request.post(endpoint, cookies=cookies)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
# Let's assert that PinnedTS was unset.
assert comment.PinnedTS == 0
def test_pkgbase_comment_pin(client: TestClient,
maintainer: User,
package: Package,